[英]Spring : annotations for @Configuration class
我是 SpringBoot 的新手,我不太明白例如這個類:
@Configuration
@EnableConfigurationProperties(...)
@ComponentScan(basePackages = {...})
@Import(SomeClass.class)
public class MyConfig {
@Bean
public IFactory myFactory(IService myService){
return new myFactory(myService);
}
...
}
@ComponentScan
? Spring 檢測到此配置的那一刻,它應該包含所有用@Bean
注釋的@Bean
no ?@Import
在這里做什么? 為什么應該導入一個類而不是用@Bean
注釋它?@Bean
和@ComponentScan
下的@ComponentScan
之間有什么關系嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.