这是一篇Spring的博客: http://blog.springsource.org/2011/02/15/spring-3-1-m1-unified-property-management/
它引入了一个新特性:导入标签中的用户占位符。
示例:<import resource="com/bank/service/${customer}-config.xml"/>
好吧,我也是 3.1。
然后,当我启动 MYAPP 时,奇迹并没有发生..
这是我的代码: (sourceFolder 中的 config.properties):
kName = P0765
(spring 的 xml):
<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">;
<property name="location" value="classpath:config.properties" >;
</bean>
<import resource="readyData/${KName}.xml"/>
:( 什么工作没做??
最佳答案
在 import 元素中解析的属性必须设置为 JVM 系统属性或系统环境变量。您在此处链接的博客文章中对此进行了描述。 这是因为合并 Spring 配置文件发生在初始化 bean 之前(PropertyPlaceholderConfigurer 是一个 bean),它可能不会改变,请参阅此被拒绝的功能请求 https://jira.springsource.org/browse/SPR-1358
关于java - 启动webApp时出现 "Could not resolve placeholder KName"异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10830521/