Spring Configuration(五):Profile

Profile:

    Profile为在不同环境下使用不同的配置提供了支持。

    (1)通过设定Environment的ActiveProfiles来设定当前context需要使用的配置环境。在开发中使用@Profile注解类或者方法,达到在不同情况下选择实例化不同的Bean。

    (2)通过设定jvm的spring.profiles.active参数来设置配置环境。

    (3)Web项目设置在Servlet的Context parameter中。



    @Profile(value = {"sit", "testing", "stage"})    



猜你喜欢

转载自blog.csdn.net/lsxf_xin/article/details/80051122