【发布时间】:2014-06-04 13:16:11
【问题描述】:
<context:property-placeholder
location="a.properties,b.properties"
ignore-unresolvable="true"/>
结果:两个属性文件都已加载
<context:property-placeholder
location="${properties_location}"
ignore-unresolvable="true"/>
其中 properties_location 是“a.properties,b.properties”
result: Exception in thread "main" org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [a.properties,b.properties] cannot be opened because it does not exist
编辑:${properties_location} 设置如下:
System.getProperties().setProperty("properties_location", "a.properties,b.properties");
ApplicationContext ctx = new GenericXmlApplicationContext("context.xml");
...
如何以第二种方式初始化我的应用程序?在占位符中定义所有属性文件的路径。
【问题讨论】:
-
你能指定你使用的是哪个spring版本吗?
-
问题是占位符在
String到String[]转换后得到解决。所以你想要的是,目前,不可能。
标签: java spring properties