使用 Eclipse 创建 Maven 项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3650592/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Create Maven project with eclipse
提问by Mercer
i want to create a Maven project in eclipse. I have install the m2eclipse plugin in my eclipse, i have create a new Maven Project, now i'm stuck with archetype, i want to create a project with Struts 2, Hibernate 3, MySql and JUnit
我想在 Eclipse 中创建一个 Maven 项目。我已经在我的 Eclipse 中安装了 m2eclipse 插件,我已经创建了一个新的 Maven 项目,现在我被原型卡住了,我想用 Struts 2、Hibernate 3、MySql 和 JUnit 创建一个项目
回答by Pascal Thivent
You shouldn't expect to find an archetype for all possible combinations, they are endless and I generally prefer to shape my own project myself, starting with basic archetypes (you can bootstrap a project using some archetypes, just don't expect to always find an ultimate generic solution).
你不应该期望为所有可能的组合找到一个原型,它们是无穷无尽的,我通常更喜欢自己塑造我自己的项目,从基本原型开始(你可以使用一些原型引导一个项目,只是不要期望总能找到最终的通用解决方案)。
In your case, you could either use the Struts 2 Blank Archetypefor the presentation part:
在您的情况下,您可以使用Struts 2 Blank Archetype作为演示部分:
mvn archetype:generate -B \
-DgroupId=tutorial \
-DartifactId=tutorial \
-DarchetypeGroupId=org.apache.struts \
-DarchetypeArtifactId=struts2-archetype-blank \
-DarchetypeVersion=2.1.8.1
And then the JPA archetype (hibernate based) for the domain part:
然后是域部分的 JPA 原型(基于休眠):
mvn archetype:generate -B \
-DgroupId=com.my-company.my-project \
-DartifactId=my-project-domain \
-DpackageName=com.company.project.domain \
-DarchetypeGroupId=com.rfc.maven.archetypes \
-DarchetypeArtifactId=jpa-maven-archetype \
-DremoteRepositories=http://maven.rodcoffin.com/repo \
-DarchetypeVersion=1.0.0
Or use the AppFuse QuickStart archetype:
mvn archetype:generate -B \
-DarchetypeGroupId=org.appfuse.archetypes \
-DarchetypeArtifactId=appfuse-basic-struts-archetype \
-DarchetypeVersion=2.1.0-M1 \
-DgroupId=com.mycompany -DartifactId=myproject
And remove all the appfuse specifc stuff (seems to be more work than going the other way i.e. adding stuff).
并删除所有 appfuse 特定的东西(似乎比其他方式(即添加东西)更多的工作)。
Or simply create a blank webapp and add the required stuff yourself. Often, this is the best thing to do as already hinted.
或者简单地创建一个空白的 web 应用程序并自己添加所需的东西。通常,正如已经暗示的那样,这是最好的做法。