In an application that I ran both locally and in Openshift, I used a permanent app-root / data folder to store any specific OpenShift configuration.
In my web.xml, I include the properties as follows:
<context:property-placeholder location="file:${user.home}/app-root/data/configuration.properties"/>
If you manage sensitive configuration properties such as usernames and passwords, envvens variables can be long. For example, you can put the following properties in your pom.xml in the openshift profile:
<properties> <db.username>${env.OPENSHIFT_POSTGRESQL_DB_USERNAME}</db.username> <db.password>${env.OPENSHIFT_POSTGRESQL_DB_PASSWORD}</db.password> <db.connectionURL>postgresql://${env.OPENSHIFT_POSTGRESQL_DB_HOST}:5432/${env.PGDATABASE}</db.connectionURL> </properties>
Get database connection properties from Openshift environment variables. Then you can use maven resource filtering to put these properties in any files in specific directories, such as src / main / resources
My own local db connection properties are managed in the profile in the ~ / .m2 / settings.xml file.
This approach allows me to:
- save all sensitive properties from my public code repository.
- it's very easy to switch between openshift and local deployment by enabling / disabling maven build profiles.
source share