Spring导入配置类或文件


第一种

spring.factories

第二种

@Import(Config.class)

第三种

@ImportResource(locations = "classpath:applicationContext.xml")

第四种

@ComponentScan
//扫描导入jar或启动类放到com目录下

第五种(导入properties等文件的配置)

导入配置文件
@PropertySource(value = {"classpath:person.properties"})
@ConfigurationProperties(prefix = "person")