How to set development/test/production environment in spring project (XML) | Code Breeze !
In real life development, a project always need different sets of configurations for development, system test and production environments. Most common variables in these different environments are database location or jms location.
If the project uses spring and will not run in any container, the spring profiles can be used to make your life easier when switching environments. This article demonstrates the best practice to do so in my experiences to achieve these goals:
- Finally there will be only one packaged jar for all different environment
- The same jar can run in development environment by giving option "-Dspring.profiles.active=development" to JVM
- The same jar can run in test environment by giving option "-Dspring.profiles.active=test" to JVM
- The same jar can run in production environment without options to JVM
- The JUnit test cases can easily switch between different environments
If your project will run within web containers, should use JNDI to define the resources and inject resources into Java code.
The basic idea is put property variables in 3 different property files, namely development.properties/test.properties/production.properties, then use the proper file for different environment ( spring active profile).
Read full article from How to set development/test/production environment in spring project (XML) | Code Breeze !
No comments:
Post a Comment