版权声明:随意转载。 https://blog.csdn.net/dengjili/article/details/85284815
maven profile
新建maven工程,创建不同环境的文件
dev
ip=192.168.1.1
test
ip=10.0.1.123
配置加载不同的文件,默认为dev
<profiles>
<profile>
<id>dev</id>
<properties>
<conf.active>dev</conf.active>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>test</id>
<properties>
<conf.active>test</conf.active>
</properties>
</profile>
</profiles>
引入资源配置
<build>
<resources>
<resource>
<directory>${basedir}/src/main/resources/conf/${conf.active}</directory>
</resource>
</resources>
</build>
默认打开,加载dev资源配置文件
打包
mvn clean install
使用反编译软件查看jar包
加载测试配置
重写打包。安装
mvn clean install -P test