If you use maven, you can use source filtering for this. Use this document for reference. I will outline the process a bit.
You will need to specify a filter path. I'm not sure if you need to explicitly define the included files.
<build> ... <resources> <resource> <directory>src/main/resources/META-INF</directory> <filtering>true</filtering> <includes> <include>**/*.xml</include> </includes> </resource> ... </resources> ... </build>
The directory you define is related to pom.xml .
Now you can define regular maven properties to replace placeholders in persistence.xml
If you want to have properties in a separate .properties file, you need to tell maven where to find this file:
<filters> <filter>db.properties</filter> </filters>
Filtering occurs on mvn resources:resources . This step is defined for all packaging purposes that you will perform during deployment.
You can use maven profiles to switch between sets of properties or .properties files.
source share