如果需要修改的项目很多而且复杂的话,则应该使用 Apache Maven 的 Profile 和 Filtering 功能来解决。
<profiles>
<profile>
<id>cluster</id>
<activation>
<property>
<name>node</name>
</property>
</activation>
<build>
<finalName>ota-app-governor</finalName>
<filters>
<filter>${project.basedir}/src/cluster/nodes/${node}.properties</filter>
</filters>
<resources>
<resource>
<targetPath>${project.basedir}/target/${project.build.finalName}
</targetPath>
<filtering>true</filtering>
<directory>${project.basedir}/src/main/sca-resources</directory>
<includes>
<include>META-INF/**/*.composite</include>
<include>definitions.xml</include>
</includes>
</resource>
<resource>
<targetPath>${project.basedir}/target/${project.build.finalName}/WEB-INF/classes
</targetPath>
<filtering>true</filtering>
<directory>${project.basedir}/src/main/resources</directory>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
<include>policy</include>
</includes>
</resource>
</resources>
</build>
</profile>
</profiles>
这是我pom的一部分
在eclipse输入clean install -Dnode=default命令,此处node是上面的变量名,运行的实际是文件default.properties
可以参考:http://www.cnblogs.com/wangdaijun/p/5359912.html;