概述
在启动springboot的项目过程中,我们可能需要打印出活动的profiles。
@SpringBootApplication
@Slf4j
public class CompanyApplication {
public static void main(String[] args) {
ApplicationContext ctx = SpringApplication.run(CompanyApplication.class, args);
String[] activeProfiles = ctx.getEnvironment().getActiveProfiles();
for (String profile : activeProfiles) {
log.warn("Spring Boot 使用profile为:{}" , profile);
}
}
}