使用 Maven 和 Eclipse Helios 创建完整的 EAR 项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6829961/
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 complete EAR Project with Maven and Eclipse Helios
提问by Hauke
I read some articles about how to set up eclipse and maven to create a new empty ear project but all solutions weren't complete or are to old.
我阅读了一些关于如何设置 eclipse 和 maven 以创建新的空耳项目的文章,但所有解决方案都不完整或过时。
I believe that I need to create three pom.xml files / or three projects:
我相信我需要创建三个 pom.xml 文件/或三个项目:
- client project with the WEB-APP structure (like a regular dynamic web project). This should result in a WAR file.
- server project with the ejbs. This should be a JAR file.
- ear project which joins both projects together.
- 具有 WEB-APP 结构的客户端项目(类似于常规的动态 Web 项目)。这应该会产生一个 WAR 文件。
- 带有 ejbs 的服务器项目。这应该是一个 JAR 文件。
- 耳朵项目将两个项目连接在一起。
I tried that with help of the integrated maven plugin in eclipse. Since (I believe Helios) maven is already integrated in eclipse. So I go to
我在 eclipse 中集成的 maven 插件的帮助下尝试了这一点。因为(我相信 Helios)maven 已经集成在 eclipse 中。所以我去
file -> new -> maven -> maven project
文件 -> 新建 -> maven -> maven 项目
and leave the "create a simple project" checkbox unchecked. On the next side I got the archetype catalog. To create the client project I looked for maven-archetype-webapp Version 1.0. But all the folders like WebContent\META-INF etc. are missing.
并取消选中“创建一个简单项目”复选框。在另一边,我得到了原型目录。为了创建客户端项目,我寻找了 maven-archetype-webapp 版本 1.0。但是所有像 WebContent\META-INF 等的文件夹都不见了。
So how can I create all three projects are build them together?
那么如何创建所有三个项目并将它们构建在一起呢?
Thanks a lot, Hauke
非常感谢,豪克
PS.: I read in question 5668710 about creating the project without maven and activate the dependency management. But is that the right way? I don't think so.
PS.:我在问题 5668710 中阅读了有关在没有 maven 的情况下创建项目并激活依赖项管理的内容。但这是正确的方法吗?我不这么认为。
回答by powerMicha
Creating the projects via console
and importing them via m2eclipse
would be the best way, as you can read it in the comments of your question.
通过创建项目并通过console
导入它们m2eclipse
将是最好的方法,因为您可以在问题的评论中阅读它。
Start off with this line in your console
从控制台中的这一行开始
mvn archetype:generate
Then use the archetype maven-archetype-j2ee-simple
然后使用原型 maven-archetype-j2ee-simple
This will generate you a project structure for ejb
, ear
and web
projects. Otherwise you can create 3 simple projects maven-archetype-quickstart
on your own and add the concering plugins
这将为您生成一个项目结构ejb
,ear
以及web
项目。否则你可以maven-archetype-quickstart
自己创建 3 个简单的项目并添加相关插件
Here is another post, handling your problem: Maven2: Best practice for Enterprise Project (EAR file)
这是另一篇文章,处理您的问题:Maven2:企业项目的最佳实践(EAR 文件)
Another nice example you can find here
另一个很好的例子,你可以在这里找到
回答by Shaikh Aziz
The best and the most clean way for creating an Enterprise Application (all the three projects ear, jar, war.... i.e. jar and war are linked into ear).... is to create through maven Enterprise Application in NETBEANS and import the whole project into Eclipse.
创建企业应用程序的最好和最干净的方法(所有三个项目ear,jar,war....即jar和war都链接到ear....是通过NETBEANS中的maven Enterprise Application创建并导入整个项目导入Eclipse。
Thanks Imran
谢谢伊姆兰