How do you maintain java webapps in different staging environments?

后端 未结 13 2540
傲寒
傲寒 2020-12-29 10:23

You might have a set of properties that is used on the developer machine, which varies from developer to developer, another set for a staging environment, and yet another fo

相关标签:
13条回答
  • 2020-12-29 11:03

    I just put the various properties in JNDI. This way each of the servers can be configured and I can have ONE war file. If the list of properties is large, then I'll host the properties (or XML) files on another server. I'll use JNDI to specify the URL of the file to use.

    If you are creating different app files (war/ear) for each environment, then you aren't deploying the same war/ear that you are testing.

    In one of my apps, we use several REST services. I just put the root url in JNDI. Then in each environment, the server can be configured to communicate with the proper REST service for that environment.

    0 讨论(0)
  • 2020-12-29 11:03

    One solution I have seen used is to configure the staging environment so that it is identical to the production environment. This means each environment has a VLAN with the same IP range, and machine roles on the same IP addresses (e.g. the db cluster IP is always 192.168.1.101 in each environment). The firewalls mapped external facing addresses to the web servers, so by swapping host files on your PC the same URL could be used - http://www.myapp.com/webapp/file.jsp would go to either staging or production, depending on which hosts file you had swapped in.

    I'm not sure this is an ideal solution, it's quite fiddly to maintain, but it's an interesting one to note.

    0 讨论(0)
  • 2020-12-29 11:05

    Separate configuration files, stored in the source control repository and updated by hand. Typically configuration does not change radically between one version and the next so synchronization (even by hand) isn't really a major issue.

    For highly scalable systems in production environments I would seriously recommend a scheme in which configuration files are kept in templates, and as part of the build script these templates are used to render "final" configuration files (all environments should use the same process).

    0 讨论(0)
  • 2020-12-29 11:07

    I have different configuration folders holding the configurations for the target deployment, and I use ANT to select the one to use during the file copy stage.

    0 讨论(0)
  • 2020-12-29 11:08

    I use Maven to filter out the resources under src/main/resources in my project. I use this in combination with property files to pull in customized attributes in my Spring-based projects.

    For default builds, I have a properties file in my home directory that Maven then uses as overrides (so things like my local Tomcat install are found correctly). Test server and production server are my other profiles. A simple -Pproduction is all it then takes to build an application for my production server.

    0 讨论(0)
  • 2020-12-29 11:09

    Use different properties files and use ant replace filters which will do the replacement based on environment for which the build is done. See http://www.devrecipes.com/2009/08/14/environment-specific-configuration-for-java-applications/

    0 讨论(0)
提交回复
热议问题