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硬编码的,你无法改变。

  • 相关阅读:
    MVC 小demo
    单例模式
    简单工厂模式
    有关ajax中的URL问题
    SqlHelper++
    C# 操作XML
    C# 注册DLL(使用cmd)
    图片延迟加载库Layzr
    解决Ajax跨域问题:Origin xx is not allowed by Access-Control-Allow-Origin.
    HTML5 + SOCKET视频传输
  • 原文地址:https://www.cnblogs.com/beiyeren/p/3488562.html
Copyright © 2011-2022 走看看