如何根据测试、开发环境打包不同的参数配置
==== maven文件(设置要替换的值) ====
development
zhang san
true
test
li si
src/main/resources
*.properties
*.xml
true
==== config.properties(要替换的资源文件) ====
a=1
b=${name} # 根据maven不同的参数替换不同的值
==== App.java ====
public static void main(String[] args) throws IOException {
Properties pps = new Properties();
pps.load(App1.class.getClassLoader().getResourceAsStream("test.properties"));
for(Object key:pps.keySet())
System.out.println(pps.getProperty(key+""));
}
==== maven 编译参数 ====
maven clean package -P development # ${name}替换成 zhang san
maven clean package -P test # ${name}替换成 li si