Reputation: 67
i have 2 external properties security.properties and env.properties and i have a key in security.properties as key1 and i want to replace this key1 value based on the env.properties key1
ex:
security.properties
hibernate.connection.url=jdbc:oracle:thin:@localhost:4521/NGI
env.properties
jdbc.url=jdbc:oracle:thin:@localhost:4521/NGI (it defers based on the environment)
i want to replace the hibernate.connection.url to jdbc.url based on the loaded environment.
I tried the following option, but i get a build failure error
<configuration>
<file>target/${project.artifactId}/security.properties</file>
<replacements>
<replacement>
<token>${hibernate.connection.url}</token>
<value>${jdbc.url}</value>
</replacement>
</replacements>
</configuration>
please share your suggestions
Upvotes: 0
Views: 4433
Reputation: 16305
I believe, what you missed in your pom was loading the env properties. You need to load that file using maven properties plugin.
However, what everyone is trying to tell you, is to keep the values from the env.properties in different profiles in your pom.xml and activate the right profile depending on your targeted environment.
Upvotes: 1
Reputation: 51
What about keeping all these URLs as property values in pom.xml instead of bunch of ".properties" files? Their values can be easily changed and overrided using profiles and they can be substituted into ".properties" files during filtered resource copying phase of Maven build.
Upvotes: 0