本篇文章为大家展示了Maven中profiles的作用是什么,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。
我们项目打包的时候需要选择具体引用哪个配置文件,product?test?dev?
而<profiles>就是指定具体的配置文件的。
<!-- profile begin -->
<profiles>
<profile>
<id>dev</id>
<activation>
<property>
<name>APP_ENV</name>
<value>dev</value>
</property>
</activation>
<properties>
<profile.env.name>env.dev.properties</profile.env.name>
</properties>
</profile>
<profile>
<id>test</id>
<activation>
<property>
<name>APP_ENV</name>
<value>test</value>
</property>
</activation>
<properties>
<profile.env.name>env.test.properties</profile.env.name>
</properties>
</profile>
<profile>
<id>product</id>
<activation>
<property>
<name>APP_ENV</name>
<value>product</value>
</property>
</activation>
<properties>
<profile.env.name>env.product.properties</profile.env.name>
</properties>
</profile>
<profile>
<id>product_cron</id>
<activation>
<property>
<name>APP_ENV</name>
<value>product_cron</value>
</property>
</activation>
<properties>
<profile.env.name>env.product_cron.properties</profile.env.name>
</properties>
</profile>
</profiles>
<!-- profile end -->
打包时执行mvn clean package -P test将触发test环境的profile配置
相对应的:
mvn clean package -P dev 触发env.dev.properties
mvn clean package -P product 触发 env.product.properties
-D代表(Properties属性)
如上对应的property的name为APP_ENV,因此可以使用如下命令
mvn clean package -DAPP_ENV=test 将触发test环境的profile配置
mvn clean package -DAPP_ENV=dev 触发env.dev.properties
mvn clean package -DAPP_ENV=product 触发 env.product.properties
上述内容就是Maven中profiles的作用是什么,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注亿速云行业资讯频道。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。
原文链接:https://my.oschina.net/weiweiblog/blog/5052753