classpath并读取spring中的属性文件

classpath并读取spring中的属性文件

本文介绍了将目录添加到tomcat classpath并读取spring中的属性文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试读取位于外部文件夹中的 test1.properties 文件.

I am trying to read the test1.properties file which is located at an external folder.

这是我的 spring 配置文件:

here is my spring config file:

<bean id="propertyConfigurer3" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="ignoreUnresolvablePlaceholders" value="true"/>
    <property name="locations">
        <list>
            <value>classpath:test.properties</value>
            <value>classpath:test1.properties</value>
        </list>
    </property>
</bean>

如果我将 test1.properties 放在 tomcat7/lib 文件夹中,我就能读取它.但是,我想将它放在与 tomcat7/env/test1.properties

if I place the test1.properties in the tomcat7/lib folder, I am able to read it.However, I want to place it in a different directory as tomcat7/env/test1.properties

我已经添加了conf/catalina.properties的路径:

common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar,${catalina.home}/env

这不起作用,请帮忙

解决方案:好吧..终于修好了..我一直在做正确的事情..是我的IDE导致了这个问题.IDE 未获取 catalina.properties 文件中的更改.我不得不在我的 IDE 中删除服务器配置并重新配置它.

solution:Ok.. finally fixed it.. I had been doing it correctly this whole time.. it was my IDE which caused the problem.The IDE was not picking up the changes in the catalina.properties file. I had to delete the server config in my IDE and re configure it.

这些链接总体上很有帮助:

these links were helpful in general:

http://www.mulesoft.com/tomcat-classpath#solutions

推荐答案

好的.. 终于修好了.. 我一直都在正确地做.. 是我的 IDE 导致了这个问题.IDE 未获取 catalina.properties 文件中的更改.我不得不在我的 IDE 中删除服务器配置并重新配置它.

Ok.. finally fixed it.. I had been doing it correctly this whole time.. it was my IDE which caused the problem. The IDE was not picking up the changes in the catalina.properties file. I had to delete the server config in my IDE and re configure it.

这些链接总体上很有帮助:

these links were helpful in general:

添加目录到 tomcat 类路径

Adding a directory to tomcat classpath

http://www.mulesoft.com/tomcat-classpath#solutions

这篇关于将目录添加到tomcat classpath并读取spring中的属性文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 08:34