1

I have a war file that will be deployed on many clients. I just want to change the configurations on database.properties file without generating a new build.

Using the code below on my applicationContext.xml spring configuration file I achieved the expected result from a jar file,

<bean id="propertyConfig" class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
      <property name="locations">
          <list>
              <value>classpath:META-INF/spring/*.properties</value>
              <value>file:./database.properties</value>
          </list>
      </property>
      <!--If false (default) then config file ("resource") must exist or exception is thrown.
          Set to true if the config file is optional-->
      <property name="ignoreResourceNotFound" value="true"/>
      <!--If false (default) then if placeholder fails to resolve throw exception-->
      <property name="ignoreUnresolvablePlaceholders" value="true"/>
</bean> 

and now I just want to deploy my war on tomcat7 and let the application search for the external property file with my database settings on the same directory where my .war is deployed, on the client machine without need the full tomcat directory path. like I realized before to the jar.

What I have to do?

MLavoie
  • 9,671
  • 41
  • 36
  • 56
  • http://stackoverflow.com/questions/20403810/tomcat-server-absolute-file-access-in-war-webapp should help you – pk87 May 14 '14 at 14:46
  • Another idea: [http://stackoverflow.com/questions/17443534/propertyplaceholderconfigurer-use-external-properties-file](http://stackoverflow.com/questions/17443534/propertyplaceholderconfigurer-use-external-properties-file) – Andrei Stefan May 14 '14 at 14:49
  • classpath:filename.properties add the file "filename.properties" to the classpath. – DwB May 14 '14 at 16:55
  • i solved my problem using the tomcat7 server downladed as zip on windows, and putting the database.properties on tomcat bin folder. – carlosfiliperegis May 14 '14 at 17:25
  • when i execute startup.bat the server load the database.properties with this configuration file:./database.properties, but i want to use tomcat as windows service... – carlosfiliperegis May 14 '14 at 17:27
  • You could found answer here http://stackoverflow.com/a/7922199/2835239 . – Yevgen Kulik Apr 09 '15 at 15:58

0 Answers0