[英]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.