首页>代码>Spring Boot配置@Profile注解加载不同环境的配置文件实例>/profiles/src/main/java/com/memorynotfound/springboot/Application.java
package com.memorynotfound.springboot; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.properties.EnableConfigurationProperties; import javax.annotation.PostConstruct; @SpringBootApplication @EnableConfigurationProperties(ApplicationProperties.class) public class Application { private static Logger logger = LoggerFactory.getLogger(Application.class); @Autowired private ApplicationProperties properties; @Autowired private Configuration configuration; public static void main(String... args) throws Exception { SpringApplication.run(Application.class, args); } @PostConstruct private void init(){ logger.info("Spring Boot - active profile: " + configuration.getName()); logger.info("Spring Boot - Choosing Your Profile and @Profile annotation example"); logger.info(properties.toString()); } }


月光橘子
3月11日
暂无贡献等级
飞翔的面包片 LV12
2月10日
yohohero LV1
1月14日
q59200182 LV9
1月1日
lewiszz LV2
2022年12月11日
fengshengtian LV8
2022年2月22日
hsc456 LV2
2021年10月8日
park96323
2021年7月23日
暂无贡献等级
15816654419 LV1
2021年6月29日
lbwnblbwnblbwnb LV7
2021年6月21日