将额外的属性传递给Maven原型:generate [英] Passing extra properties to maven archetype:generate

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

问题描述

我已经为自定义项目设置创建了一个Maven原型,该模板工作得很好,但是我想知道是否可以传递额外的参数,以便我做一些更有趣的模板.我尝试过类似的

I've created a Maven archetype for a custom project setup, which is working wonderfully, but I was wondering if it's possible to pass extra parameters so that I can do some more interesting templating. I tried something like

mvn archetype:generate -DarchetypeCatalog=local -DdbHost=localhost

放入

...
<option name="db.host.config.option" value="${dbHost}" />
...

在我的模板中,但这似乎不起作用.有没有办法用原型做到这一点?

in my template, but that doesn't seem to work. Is there a way to do this with an archetype?

推荐答案

您只需在META-INF/maven/archetype-metadata.xml中将dbHost称为requiredProperty.

<archetype-descriptor name="basic">
    <requiredProperties>
        <requiredProperty key="dbHost"/>
    </requiredProperties>
</archetype-descriptor>

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

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