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

原文地址:https://www.cnblogs.com/tonggc1668/p/8535425.html