pom.xml配置html
<profiles> <profile> <id>dev</id> <properties> <token>dev</token> </properties> <!-- 默認打包參數 --> <activation> <activeByDefault>true</activeByDefault> </activation> </profile> <profile> <id>test</id> <properties> <token>test</token> </properties> </profile> </profiles> <build>
<!-- 開啓資源配置--> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> </resources> </build>
test.propertiesjava
token=${token}
*.java // 獲取參數的java類ui
public class TokenTestPom { private static ResourceBundle resource = ResourceBundle.getBundle("token"); public static final String TOKEN= resource.getString("token"); }
項目打包命令:xml
mvn install -Ptesthtm