//注入
@Autowired
private Environment environment;
//active默认值
private String active = "dev";
//获取环境中的active(local、dev、test、prod)
String[] activeProfiles = environment.getActiveProfiles();
if (activeProfiles!=null && activeProfiles.length>0){
active = activeProfiles[0];
}
springboot分环境
于 2021-05-19 17:36:37 首次发布