Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a directory to tomcat classpath and read the property file in spring

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

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>

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

I have added the path to the the conf/catalina.properties:

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

This its not working, please help


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:

  • Adding a directory to tomcat classpath

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

like image 678
user1561521 Avatar asked Sep 10 '25 22:09

user1561521


1 Answers

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:

Adding a directory to tomcat classpath

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

like image 81
Andrés Oviedo Avatar answered Sep 13 '25 17:09

Andrés Oviedo