1.basepackages 方式 :br/>最简单
@Configuration
@ComponentScan(basePackages = {"package.**"})
2.注解方式:
@Configuration
@ComponentScan("package")
public class TestConfig {
}
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
@Documented
@Import({TestConfig.class})
public @interface EnableTestConfig {
}
@EnableLogRecordClient
@Configuration
public class Test {
}
3.spring 主动发现方式:
resources/META_INF/spring.factories 文件
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
package.class
转载于:https://blog.51cto.com/5013162/2376009