java 将eclipse java项目转换为maven模块项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7831592/
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
Convert eclipse java project to maven module project
提问by user553710
I have java project, i want to convert a multi-module project (module). I have a parent project, i want to add my existing project in parent. I like a eclipse style file structure does it possible to add existing project in Parent.
我有java项目,我想转换一个多模块项目(模块)。我有一个父项目,我想在父项目中添加我现有的项目。我喜欢 eclipse 样式的文件结构,是否可以在 Parent 中添加现有项目。
Thank you,
谢谢,
Regards and Metta, Ichiro hang
问候和慈心,一郎挂
回答by Sean Patrick Floyd
First create pom.xml files in all projects, then:
首先在所有项目中创建 pom.xml 文件,然后:
Old school:
老套:
Run mvn eclipse:eclipse
, switch to eclipse and do Import > Existing Projects
运行mvn eclipse:eclipse
,切换到 eclipse 并执行Import > Existing Projects
New School:
新学校:
Install m2e, don't run eclipse:eclipse (because it has no effect on m2e) and do Import > Maven > Existing Maven Projects
安装m2e,不要运行eclipse:eclipse(因为它对m2e没有影响)然后做 Import > Maven > Existing Maven Projects
Don't mix the two, they are not compatible with each other.
不要将两者混用,它们彼此不兼容。
回答by Edson Jord?o
You have to configure the pom.xml of the child project ("D"). You need to insert the tag with the follow configuration: groupId, artifactId and version.
您必须配置子项目(“D”)的 pom.xml。您需要使用以下配置插入标签:groupId、artifactId 和 version。
And into the parent's pom.xml you need to add the new module child ( tag).
在父级的 pom.xml 中,您需要添加新的子模块(标记)。
e.g. D pom.xml
例如 D pom.xml
<parent>
<groupId>com.project.A</groupId>
<artifactId>A</artifactId>
<version>1.0.0</version>
</parent>
A pom.xml
一个 pom.xml
<modules>
<module>D</module> --> It is the artifact Id
<module>...</module>
<module>...</module>
</modules>
回答by lobster1234
Install Maven Plugin for Eclipse(m2e). Then in your project (command line), at the root level type mvn eclipse:eclipse
. Reimport the generated project in Eclipse (Import Existing Projects into Workspace) and you should be all set.
为 Eclipse(m2e)安装Maven 插件。然后在您的项目(命令行)中,在根级别键入mvn eclipse:eclipse
. 在 Eclipse 中重新导入生成的项目(将现有项目导入工作区),您应该一切都准备好了。