Play!Framework provides a very good feature that enable you to configure different set of configurations, hence I could have something like
storage=fs
storage.fs.home.dir=...
storage.fs.home.url=...
...
%at.storage=s3
%at.storage.s3.key=...
%at.storage.s3.secret=...
...
%prod.storage=s3
%prod.storage.s3.key=...
%prod.storage.s3.secret=...
...
By default the application is use fs (filesystem) storage, if application started using --%at
(acceptance test) mode, it uses aws s3 as storage implementation, and if application started with --%prod
, the production mode, it also use s3 storage but could with different S3 configuration. This feature makes it very easy to version control the application configuration file, you don't need to update configuration file when deploy to a live server or acceptance testing server.
I am curious has anyone implemented certain mechanism for a Spring framework based application.
Try it like this, create different directories in the root of the classpath, containing the configuration of the different environments. Keep the same file names:
Then at application startup, pass in an environment variable that says which environment to use. For example:
configure the loading of a given properties file depending on the environment variable using util:properties like this: