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
时间: 2024-11-08 22:15:29