首页 > 编程语言 > 详细

[Java Spring] @Profile

时间:2020-12-04 16:43:00      阅读:27      评论:0      收藏:0      [点我收藏+]

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

技术分享图片

技术分享图片

[Java Spring] @Profile

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!