Maven原型属性替换 [英] maven archetype property substitution

查看:111
本文介绍了Maven原型属性替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都知道可以在archetype-metadata.xml中用一个默认值requredProperty替换为另一个requredProperty吗?

Anybody knows is it possible to make substitution for default value of one requredProperty to another in archetype-metadata.xml ?

所以,我尝试做这样的事情:

So, I try to do something like this:

<requiredProperty key="name"/>
<requiredProperty key="groupId">
   <defaultValue>com.mycompamy.${name}</defaultValue>
</requiredProperty>

但是当我开始以交互方式从工件生成项目时,maven首先问我有关groupId属性的问题.但是不像我预期的那样name.

But when I start to generate project from artifact in interactive mode, maven asks me about groupId property first. But not for name as I expected.

是否可以更改此行为?

推荐答案

您的问题是由required property加载顺序引起的. Maven按字母顺序加载每个自定义required property.您可能无法更改.但是有两种方法可以解决您的问题:

Your problem is caused by required property loading order. Maven loads every custom required property in alphabetical order. You probably cant change it. But there are 2 ways which will solve your problem:

  1. 重命名您的变量,如下所示:

  1. Renaming ur variables like this:

"0_name"

"1_groupId"

现在它将首先询问您姓名.

Now it will ask you about name firstly.

使用完整的maven命令,仅传递名称参数

Use full maven command, passing only name parameter

mvn archetype:generate -DarchetypeGroupId=?? -DarchetypeArtifactId=?? -DgroupId=?? -DartifactId=?? -Dversion=?? -Dpackage=?? -Dname=??

用有效参数替换??

希望它会对您有所帮助.

Hope it will helps you.

现在我看到一个asked time.有点题外话,但也许会帮助别人

now i see an asked time. Pretty offtopic but maybe it will help someone else

这篇关于Maven原型属性替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆