用junit 4创建POM [英] create POM with junit 4

查看:300
本文介绍了用junit 4创建POM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Maven 3.0.4,并且希望默认具有junit 4.

I use Maven 3.0.4 and want to have junit 4 by default.

我的项目是使用命令创建的:
$> mvn原型:create -DgroupId = my.group.id -DartifactId = myArtifactId -DpackageName = my.package.name

这将对创建的pom.xml中的junit版本3.8.1造成依赖,尽管版本4.8.1已经存在.
我的全局settings.xml中没有对junit的依赖,并且我没有本地.m2/repository/settings.xml.我不想删除旧版本3.8.1,但是希望所有新项目都使用版本4.8.1创建.

我可以在settings.xml中执行此操作(全局或本地无关紧要)吗?如果是的话,正确的语法是什么?

My projects are created with the command :
$>mvn archetype:create -DgroupId=my.group.id -DartifactId=myArtifactId -DpackageName=my.package.name

This puts a depency to junit version 3.8.1 in the created pom.xml, dispite the fact that verion 4.8.1 is already present.
There are no dependencies to junit in my global settings.xml, and I haven't a local .m2/repository/settings.xml. I don't want to remove the old version 3.8.1., but want that all new projects are created with version 4.8.1

Can I do this in my settings.xml (global or local does not matter)? And if so what is the correct syntax?

推荐答案

几件事:

archetype:createarchetype:generate弃用;请使用generate,它在您的示例中可以与create互换.

archetype:create is deprecated by archetype:generate; please use generate, it's interchangeable with create in your example.

对于解决方案,我想说的最简单的方法是生成您的项目,编辑pom以具有正确的junit版本;然后在您的项目中运行:

As for a solution, I'd say the simplest thing to do is generate your project, edit the pom to have the correct junit version; and then from within your project run:

mvn archetype:create-from-project 

这将根据您的修改创建原型,您只需要使用以下命令进行安装:

Which will create an archetype based on your modifications, you simply need to install this with:

cd target/generated-sources/archetype/
mvn install

现在,您可以使用以下新原型创建新的Maven项目:

Now you can create new maven projects with this new archetype as you like with:

mvn archetype:generate -DgroupId=my.group.id -DartifactId=newArtifact -DpackageName=my.package.name -DarchetypeArtifactId=myArtifactId-archetype -DarchetypeGroupId=my.group.id

希望这会有所帮助.

这篇关于用junit 4创建POM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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