我有一个Spring Boot应用程序如下:
@SpringBootApplication
@PropertySource(ignoreResourceNotFound=true,value={"classpath:application.properties","classpath:util-${spring.profiles.active}.properties"})
@ComponentScan("com.jmarts")
@EnableTransactionManagement
public class Application extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Override
protected SpringApplicationBuilderconfigure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
}
如果没有配置,我认为spring boot会注册一个PropertySourcesPlaceholderConfigurer。
答案 0 :(得分:0)
春季靴子正式支持profile-specific properties using the naming convention application-{profile}.properties 所以你可以删除" classpath:util - $ {spring.profiles.active} .properties"并在类路径中添加application-local.properties,application-dev.properties等。