• spring profile


    配置,激活profile. 处理测试环境,开发环境,生成环境的不同配置.

    Javaeconfig配置Profile

    @Profile注解指定某个bean属于哪一个profile

    xml配置Profile

    可以在根<beans>元素中嵌套定义<beans>元素,而不是为每个环境都创建一个profileXML文件。这能够将所有的profile bean定义放到同一个XML文件中

    激活profile

    Spring在确定哪个profile处于激活状态时,需要依赖两个独立的属性:spring.profiles.active和spring.profiles.default。如果设置了spring.profiles.active属性的话,

    那么它的值就会用来确定哪个profile是激活的。但如果没有设置spring.profiles.active属性的话,那Spring将会查找spring.profiles.default的值。如果spring.profiles.active

    spring.profiles.default均没有设置的话,那就没有激活的profile,因此只会创建那些没有定义在profile中的bean.

    系统会优先使用spring.profiles.active中所设置的profile

    有多种方式来设置这两个属性:
    作为DispatcherServlet的初始化参数;
    作为Web应用的上下文参数;
    作为JNDI条目;
    作为环境变量;
    作为JVM的系统属性;
    在集成测试类上,使用@ActiveProfiles注解设置。

  • 相关阅读:
    MySQL数据库 : 高级查询
    ElasticSearch : High Rest Api 使用
    Java : JavaWeb和Tomcat相关
    Linux : Ubuntu 安装 RabbitMQ
    Spring : Spring Security
    Java : logback简单配置
    Spring : JPA的单独使用
    Java : Netty 入门案例
    python__PIP : 安装第三方库
    好文章收藏(持续更新)
  • 原文地址:https://www.cnblogs.com/tulianghui/p/7278669.html
Copyright © 2020-2023  润新知