【问题标题】:Spring 3.2 resource file loading issueSpring 3.2 资源文件加载问题
【发布时间】:2012-11-21 10:27:29
【问题描述】:

我有以下资源文件的 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 构建程序集。

项目结构:

项目名称 | |--主要 |-- 爪哇 |-- 资源

另外,我正在使用此链接 (http://stackoverflow.com/questions/13615634/maven-build-assembly-with-dependencies) 使用 maven 配置

【问题讨论】:

  • 您遇到异常了吗?你能添加堆栈跟踪吗?

标签: java spring maven


【解决方案1】:

目前没有足够的信息来确切地知道发生了什么。但在我看来,context.xml 中存在一些混淆。首先,我建议将以上所有内容替换为

<context:property-placeholder location="classpath:/Application.properties, classpath:/database.properties" />

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2020-08-28
  • 2014-12-04
  • 2018-03-26
  • 2015-11-16
  • 2014-11-21
  • 1970-01-01
  • 2020-12-10
  • 1970-01-01
相关资源
最近更新 更多