方式一:spring.profiles.active
resources/application.properties中
propertiesspring.profiles.active=devresources/application.yml中
ymlspring: profiles: active: dev
方式二:命令行激活
shell
java -jar app.jar --spring.profiles.active=dev方式三:idea和eclipse的配置


方式四:启动程序中设置(不推荐)
public static void main(String[] args) {
SpringApplication app = new SpringApplication(YourApplication.class);
app.setAdditionalProfiles("prod");
app.run(args);
}