[Java Spring] @Profile

时间:2020-12-04 16:43:00   收藏:0   阅读:28

For example, inside code, we want production env & dev env print different time format.

    @Bean
    @Profile("!dev")
    public TimeService timeService(){
        return new TimeService(true);
    }

    @Bean
    @Profile("dev")
    public TimeService timeService12(){
        return new TimeService(false);
    }

 

Setup VM Options: 

-Dspring.profiles.active=prod
// or
-Dspring.profiles.active=dev

技术分享图片

技术分享图片

原文:https://www.cnblogs.com/Answer1215/p/14086334.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!