Announcement Announcement Module
No announcement yet.
Deploying web apps - dev, test, production configuration Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Deploying web apps - dev, test, production configuration


    I can't find any references to how people are configuring applications for different servers. Ideally I should be able to put some sort of application specific configuration file on the server in question before I deploy a WAR. Otherwise deploying to a live Tomcat server cluster would be a nightmare! (deploy, stop the app, alter web.xml, restart -- not an acceptable way to do things!)

    How are you achieving this? I just want a simple file somewhere with the key server specific parameters such as which Oracle database to target and whether to cache files. We currently use dev, test, beta and live servers and it is not good to repackage the WAR for each server since the binaries should be identical or the testing doesn't hold water.

    Also, certain parameters would ideally be shared - for example most, if not all the applications on live will target the same database, so there should be no need to define the connect URL in multiple places on the same server.

    Thanks in advance for any input...

  • #2
    This question is not really Spring related, but you should have a look at Ant or Maven.


    • #3
      Spring provide some nice "out of the box" support for configuring your application context using property files.

      I always try and have a web.xml file that does not require any changes between production and test environments. I achieve this by moving as much configuration as is possible out of web.xml and into the spring application context. For servlets if you're using Spring MVC this is easy for filters check out FilterToBeanProxy which part of the Acegi Security framework.



      • #4

        Look at the classes:

        org.springframework.beans.factory.config.PropertyO verrideConfigurer
        org.springframework.beans.factory.config.PropertyP laceholderConfigurer

        These allow you externalize properties so that your values will be filled in or overriden when the app starts. I use these to configure my datasource, a different on per platform, ie. dev, qa, pre-prod, prod. Remember, you can use ant-style variables in your bean configuration files.

        Other than a datasource, what are you trying to parameterize? Try to put all your platform specific properties in separate properties files and load the correct one, using one of the classes above, and it should dynamically re-configure for you.

        Also, if you are using an o/r mapper like hibernate, use the abilites of hibernate configuraton to change your environments. You could define a default hibernate.cfg.xml and a in the classpath will override default cfg file.

        Hope this helps.