属性文件未在Unix机器中加载,但同样在Windows机器上工作. 不明白为什么?



我正在使用Spring 4.3.6和tomcat 7作为我们的Web应用程序。我的xml文件中有以下配置:-

<bean id="appResourcesProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="locations">
<list>
<value>classpath*:resourcesxxxxxxResources.properties</value>
</list>
</property>
</bean> 

这在Windows机器上工作正常,但是当在unix机器上部署相同的属性文件时,没有加载属性文件。

然后我删除了类路径后的"*"并修改如下:-

<bean id="appResourcesProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="locations">
<list>
<value>classpath:resourcesWCApplicationResources.properties</value>
</list>
</property>
</bean> 

这在 unix 机器上工作正常。为什么会这样?我无法理解原因。有人可以帮助我理解这一点吗?提前感谢。

原因是"\",请尝试改用"/",例如resources/WCApplicationResources.properties

类路径*:可移植性

通配符类路径依赖于 底层类加载器.... 如果返回了不适当的结果,请查看应用程序服务器文档以了解可能影响类装入器行为的设置。

getResources发现是这样的:

The name of a resource is a '/'-separated path name that identifies the resource. 

希望它有所帮助。

最新更新