which has a configuration item:
<property name="url" value="${db-url}&useOldAliasMetadataBehavior=true" />
Where ${db-url} has different values according to different environments.
At this time, mvn profile will be used.
First define the profile:
<profile> <!-- uat runtime environment--> <!-- Execute when packaging: mvn clean install -P uat -Dmaven.test.skip=true --> <id>uat</id> <properties> <db-url>jdbc:mysql://xxxxxx:3312/xxxxx?characterEncoding=utf-8</db-url> </properties> </profile>
To allow the values defined by this profile to be assigned to db.xml, another mvn plugin is required:
resources> <!-- Tell maven to pack all the files in the src/main/resources path into jar when packing --> <resource> <directory>src/main/resources</directory> </resource> <!-- Tell maven to replace the placeholder ${XXX} in this file when telling all OSGI-INF/blueprint/database-config.xml in the src/main/resources path when packaging it --> <resource> <directory>src/main/resources</directory> <includes> <include>db.xml</include> <include>OSGI-INF/blueprint/blueprint.xml</include> </includes> <filtering>true</filtering> </resource> </resources>
When packaging, execute this command to assign the profile:
mvn clean install -P uat -Dmaven.test.skip=true