zoukankan      html  css  js  c++  java
  • spring properties resolve 问题

    在stackoverflow上看到一个问题
    配置如下:
    <context:property-placeholder location="/WEB-INF/application-customer-dev.properties,classpath:application-customer.properties" ignore-resource-not-found="true"/>
    
    <import resource="classpath*:com/x/core/security/security-${login.security}.xml"/>
    在application-customer.properties中有配置项:
    login.security=dev
    可是import却没能按照期望的发生。
    解释如下:
    大概spring context解析过程如下:

    Basically Spring XML context setup goes more or less like this:

    1、Context is created.

    2、Environment is set.

    3、XML is read (all XML, resolving imports if necessary). Bean definitions are created.

    4、BeanFactoryPostProcessors are installed and invoked, processing bean definitions.

    5、BeanPostProcessors are installed.

    6、Beans are instantiated according to the bean definitions. BeanPostProcessors are applied.

    PropertySourcesPlaceholderConfigurer 是一个BeanFactoryPostProcessor,这样的话,import必然发生在BeanPostProcessors 之前,也就无法解析。这是spring硬编码的,你无法改变。

  • 相关阅读:
    rip协议
    IP地址的计算以及子网掩码的计算
    jQuery知识点
    JavaScript 语言编程学习路线
    JS中AJAX知识
    .以及JDK1.5ConcurrentHashMap新特性
    Java程序执行顺序
    观察者设计模式
    Servlet中Filter的学习
    JDBC和连接池知识点
  • 原文地址:https://www.cnblogs.com/beiyeren/p/3488562.html
Copyright © 2011-2022 走看看