我现在正在尝试创建一个 Maven 原型,它使用spring + mybatis
框架。有一个mybatis xml文件:src/main/resources/archetype-resources/src/main/resources/sql/myapp/DemoUser.xml
,并执行以下命令以使用此原型创建新项目。
mvn archetype:generate ... -DartifactId=foo.bar -Dpackage=com.foo.bar ...
我想更换myapp
to bar
,也就是我想要的mybatis xml文件中sql/bar
文件夹,如何实现?
我的方法是在src/main/resources/META-INF/maven/archetype-metadata.xml
添加此属性
<requiredProperty key="appName">
<defaultValue>${appName}</defaultValue>
</requiredProperty>
Then in src/main/resources/archetype-resources/pom.xml
to add
#set ($artifactId = "${artifactId}")
#set ($index = $artifactId.indexOf('.'))
#set ($index = $index + 1)
#set ($appName = $artifactId.substring($index))
并记住将文件夹名称更改为
src/main/resources/archetype-resources/src/main/resources/sql/__appName__/DemoUser.xml
所以当你执行mvn archetype:generate ... -DartifactId=foo.bar ...
现在,你可以获得
│ └── resources
│ └── sql
│ └── bar
│ └── DemoUser.xml
参考文档:http://maven.apache.org/archetype/archetype-models/archetype-descriptor/archetype-descriptor.html http://maven.apache.org/archetype/archetype-models/archetype-descriptor/archetype-descriptor.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)