Note that there are some explanatory texts on larger screens.

plurals
  1. POHandling of configuration files in Spring web applications
    primarykey
    data
    text
    <p>I have several times ran into the same problem, and I would like to have some input on what other people think about the issue: Suppose we have Spring application packaged as a <strong>.war</strong> file and we want to run it on <strong>several environments</strong>. (development/test/preprod/prod/etc)</p> <p>For accessing the infrastructure needed by the application, (databases/webservices etc) we store the access info in configuration files, also some business configuration is in those files. Let's say we use <strong>.properties</strong> files for this purpose (because we have a spring application inside the war and we like having the properties read by a one-liner in the appcontext) and also suppose that in the different environments we don't have the same appserver/servlet container. (eg: dev, test: jetty, preprod: tomcat, prod: glassfish)</p> <p>What I usually have done is creating multiple <strong>Maven profiles</strong>, one for each environment, the needed configuration in the appropriate files for each. </p> <p>Now recently I have faced a question from a guy running operations: 'So really we have to generate a new build with the appropriate profile on the buildserver if the DB is changed in preprod environment?' I answered 'No, you can actually go to .../webapps/currentApp/WEB-INF/classes/config/application.properties and change the values there, then restart the container'</p> <p>We have come up with a solution which solves some aspects of this issue: using Maven assembly plugin we embed a Jetty <em>inside</em> the war which makes it usable as an 'executable' war, also giving us the possibility to have a global configuration XML, from which the starter of the embedded Jetty creates/modifies the appropriate .properties files in the exploded war directory and only then starts the application.</p> <p>But again this doesn't solve the issue if you want to use anything else other than Jetty.</p> <p>How is everyone dealing with the same situation?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload