[英]Eclipse: Import "Existing Maven Projects" create EAR project automatically
I have a bizarre behavior with Eclipse when I try to import an existing maven project, it's a multi-module JEE maven project with a parent and sub-modules.当我尝试导入一个现有的 maven 项目时,我对 Eclipse 有一个奇怪的行为,它是一个带有父模块和子模块的多模块 JEE maven 项目。 The structure svn looks like this:
svn 的结构如下所示:
When I import the project into Eclipse, it automatically create a "shared-libraryEAR" in the same directory of the "parent" project.当我将项目导入 Eclipse 时,它会自动在“父”项目的同一目录中创建一个“共享库EAR”。 It looks something like this after the import:
导入后看起来像这样:
It does this for every "jar" maven projects in the workspace.它为工作区中的每个“jar”Maven 项目执行此操作。 It's something normal ?
这是正常的事情吗? I use Eclipse Oxygen.2 and Eclipse Neon.3 with WebSphere plugins and the default embedded maven.
我使用带有 WebSphere 插件和默认嵌入式 maven 的 Eclipse Oxygen.2 和 Eclipse Neon.3。
I can reproduce the same behavior using the demo project in this Stackoverflow answer: Maven2: Best practice for Enterprise Project (EAR file)我可以使用此 Stackoverflow 答案中的演示项目重现相同的行为: Maven2:企业项目的最佳实践(EAR 文件)
After importing the project into Eclipse Oxygen, I have two new EAR project that did not exist in the original project structure.将项目导入Eclipse Oxygen后,我有两个新的EAR项目,原来的项目结构中不存在。 The structure in Eclipse Enterprise Explorer looks like this after the import:
导入后 Eclipse Enterprise Explorer 中的结构如下所示:
Result in eclipse: Image capture of Eclipse Enterprise Explorer Eclipse 中的结果: Eclipse Enterprise Explorer 的图像捕获
After importing the projects, I usually just delete the unnecessary EAR projects, but it's kind of annoying, is there a solution?导入项目后,我通常只是删除不必要的EAR项目,但是有点烦人,有什么解决方案吗?
Thanks.谢谢。
Trying a fresh copy of eclipse (the same version) solved my problem regarding to this case.尝试 eclipse 的新副本(相同版本)解决了我关于这种情况的问题。 I guess, it happened because of a plugin on eclipse.
我猜,这是因为 eclipse 上的一个插件。
I had a similar experience and ran across https://wiki.eclipse.org/M2E-WTP/New_and_Noteworthy/1.1.0 .我有过类似的经历,并且遇到了https://wiki.eclipse.org/M2E-WTP/New_and_Noteworthy/1.1.0 。
m2e-wtp can also be disabled via the m2e.wtp.activation>false in the Maven section of your project pom;xml.
也可以通过项目 pom;xml 的 Maven 部分中的 m2e.wtp.activation>false 禁用 m2e-wtp。
I create a new workspace and cloned a fresh copy of my code in a temp directory.我创建了一个新工作区,并在临时目录中克隆了我的代码的新副本。 I then updated the parent pom.xml with the following:
然后我用以下内容更新了父 pom.xml:
<properties>
<m2e.wtp.activation>false</m2e.wtp.activation>
<m2e.jaxrs.activation>false</m2e.jaxrs.activation>
<m2e.jpa.activation>false</m2e.jpa.activation>
<m2e.jsf.activation>false</m2e.jsf.activation>
<m2e.cdi.activation>true</m2e.cdi.activation>
</properties>
I then imported Existing Maven Projects
and no extra EAR projects.然后我导入了
Existing Maven Projects
,没有额外的 EAR 项目。
This ill behaviour is the result of having IBM's WebSphere plugins for Eclipse.这种不良行为是 IBM 为 Eclipse 提供 WebSphere 插件的结果。
Removing these plugins from Eclipse, or starting with a fresh Eclipse install (like the accepted answer suggests), is not sufficient.从 Eclipse 中删除这些插件,或者从全新的 Eclipse 安装开始(如已接受的答案所建议的那样),是不够的。
You will also need to create a new Eclipse workspace.您还需要创建一个新的 Eclipse 工作区。
I haven't got the time yet to figure out why, but that's the only thing that worked for me.我还没有时间弄清楚原因,但这是唯一对我有用的方法。
Preferences>Java EE>Project>Enterprise Application Membership>Add project to an EAR Preferences>Java EE>Project>Enterprise Application Membership>Add project to an EAR
uncheck that checkbox to avoid the creation of EAR projects.取消选中该复选框以避免创建 EAR 项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.