spring不同环境下用不同的配置文件

@Configuration
@PropertySource("xx-${spring.profiles.active}.properties")
public class TopologyContext {}

 

  @Bean
  @Profile({"uat", "prod"})

 

设置默认值很简单

  @Value("${NamesrvAddr:192.168.0.1}")

  private String namesrvAddr;

 

src/main/resources/xx-dev.properties

VM arguments -Dspring.profiles.active=dev

 

 

 

posted @ 2018-03-09 18:42  tonggc1668  阅读(138)  评论(0编辑  收藏  举报