Springboot配置 1. 全局yml,properties文件 application.yml: 1.写yml文件 2. 在类中配置属性,@Component @ConfigurationProperties(prefix=“emp”) 3. @autowired 2. 局部配置 emp.yml/properties 1. 配置注入时加一行 @PropertySource(value={“classpath:emp.properties”}) 3. xml配置bean: 1. 写spring01.xml 2. main中加载到容器:@ImportResource(location="…xml") 3. @autowired 4.自定义Config: 1. 写一个empConfig方法,返回一个new的组件对象,类前加@Configuration,方法前加@bean 2. @autowired 测试环境,生产环境配置 application-dev.properties 1.在application-dev.properties中写好配置 2.application.properties中指定spring.profiles.active=dev 3.如果yml,直接在主配置文件中配置