據我瞭解,當使用依賴注入時,所有Bean都在Start上初始化。Spring Standard Bean Injection vs. Autowiring
<bean id="userPreferences" class="com.foo.UserPreferences">
</bean>
<!-- a singleton-scoped bean injected to the above bean -->
<bean id="userService" class="com.foo.SimpleUserService">
<!-- a reference to the userPreferences bean -->
<property name="userPreferences" ref="userPreferences"/>
</bean>
並且上面的配置表示應用程序啓動時創建的userService和userPreferences。這是對的嗎?
當使用自動裝配和使用<context:component-scan>
public class SimpleUserService{
@Autowired
UserPreferences userPreferences;
//omitted
}
1)userPreference上應用init建立?
2)什麼是autowire注入的bean的默認範圍,我們如何改變它?
3)如何影響bean創建和bean注入?
希望我說清楚了。