首页>代码>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());

    }

}
最近下载更多
最近浏览更多
qq1357574774  LV2 2023年8月11日
845448008  LV3 2023年6月24日
szf123  LV12 2023年5月30日
海盗来了  LV20 2023年3月23日
月光橘子 2023年3月11日
暂无贡献等级
飞翔的面包片  LV12 2023年2月10日
yohohero  LV1 2023年1月14日
q59200182  LV9 2023年1月1日
lewiszz  LV2 2022年12月11日
fengshengtian  LV8 2022年2月22日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友