当然不一样。我今天在做springbatch的 job时遇到了同样的问题,到
谷歌搜了一下:
A bean with scope prototype just means that everytimeApplicationContext.getBean is called a new instance of the bean is created. If you try to inject a prototype bean in a singleton, your prototype bean will be injected once (and so is no more a prototype).
大意就是说spring管理的bean默认是
单例模式,这种情况下autowired和getbean拿到的没区别,但是如果你加入了@Scope(SCOPE_PROTOTYPE)那么就必须用getbean去拿否则这个注解没有任何意义