[英]Spring 3.2 resource file loading issue
我对资源文件使用了以下spring配置,当我在eclipse环境中执行时,它可以很好地工作。 但是,当我将应用程序打包到JAR中并执行时,文件属性文件资源不存在。
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="locations">
<list>
<value>classpath:Application.properties</value>
<value>classpath:database.properties</value>
</list>
</property>
</bean>
<!-- define the properties file to use -->
<util:properties id="appProperties" location="classpath:Application.properties" />
当我看到jar文件时,所有文件都存在。 我正在使用Maven构建程序集。
项目结构:
项目名称| | --main |-Java |-资源
另外,我正在使用通过此链接进行的Maven配置(http://stackoverflow.com/questions/13615634/maven-build-assembly-with-dependencies)
目前没有足够的信息确切地了解正在发生的事情。 但是我认为context.xml中有些混乱。 首先,我建议将上述所有内容替换为
<context:property-placeholder location="classpath:/Application.properties, classpath:/database.properties" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.