maven动态启用profile

tigermfh 2011-05-09 12:07:02
如何通过pom中的属性动态启用profile
例如:
<properties>
<enableTestProfile>true</enableTestProfile>
</properties>
<profiles>
<profile>
<id>test</id>
</profile>
</profiles>
我想根据enableTestProfile不同的取值去启用或禁用test
...全文
243 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
yingzhuo2011 2011-05-10
  • 打赏
  • 举报
回复
settings.xml 有两个啊。 一个在 ${M2_HOME}/config 下,这个一般整个项目组保持一致。

还有一个在 ${USER}/.m2 下,这个根据个人习惯改动几下没有关系的吧。
tigermfh 2011-05-10
  • 打赏
  • 举报
回复
不想在settings.xml里面配置呀,不过还是谢谢了
magong 2011-05-10
  • 打赏
  • 举报
回复
如果属性不做它用,仅用于激活/关闭profile,不如不用了,
直接用
<activeProfiles>
<activeProfile>TestProfile</activeProfile>
</activeProfiles>
好了。
tigermfh 2011-05-09
  • 打赏
  • 举报
回复
我现在就只想取pom文件里面定义的属性还有maven版本是2.x的
magong 2011-05-09
  • 打赏
  • 举报
回复
补充:上面说的是系统属性(system property)
magong 2011-05-09
  • 打赏
  • 举报
回复
The profile below will activate the profile when the system property "enableTestProfile" is specified with value "true":


<profiles>
<profile>
<activation>
<property>
<name>enableTestProfile</name>
<value>true</value>
</property>
</activation>
...
</profile>
</profiles>

67,550

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧