如何使用Eclipse为Java项目创建pom.xml [英] How to create the pom.xml for a Java project with Eclipse
问题描述
我已经有一个小型Java项目了。我想将它移动到Maven,所以我想使用Eclipse创建pom.xml,以便我可以在命令提示符下使用pom构建它。我之前没有使用Maven,虽然我使用过Ant。
I already have a small Java project. I want to move it to Maven, so I want to create the pom.xml using Eclipse so that I can build it using pom from a command prompt. I have not worked with Maven before, though I have worked with Ant.
如何使用Eclipse为我的Java项目创建pom.xml?
How can I create the pom.xml for my Java project using Eclipse?
推荐答案
您应该在Eclipse中使用新的可用m2e插件进行Maven集成。在该插件的帮助下,您应该创建一个新项目并将您的源移动到该项目中。以下是这些步骤:
You should use the new available m2e plugin for Maven integration in Eclipse. With help of that plugin, you should create a new project and move your sources into that project. These are the steps:
- 检查Eclipse发行版中是否安装了m2e(或前m2eclipse)。如果没有,请安装它。
- 打开新建项目向导:
文件>新>项目...
- 打开
Maven
并选择Maven Project
并单击下一步
。 - 选择
创建一个简单项目
(跳过原型选择)。 - 添加必要的信息:Group Id,Artifact Id,Packaging ==
jar
,以及名称。 - 完成向导。
- 现在生成了新的Maven项目,您可以将源和测试包移动到相关的工作区中的位置。
- 之后,您可以通过选择项目来构建项目(在Eclipse中),然后从上下文菜单中调用
Run as> Maven安装
。
- Check if m2e (or the former m2eclipse) are installed in your Eclipse distribution. If not, install it.
- Open the "New Project Wizard":
File > New > Project...
- Open
Maven
and selectMaven Project
and clickNext
. - Select
Create a simple project
(to skip the archetype selection). - Add the necessary information: Group Id, Artifact Id, Packaging ==
jar
, and a Name. - Finish the Wizard.
- Your new Maven project is now generated, and you are able to move your sources and test packages to the relevant location in your workspace.
- After that, you can build your project (inside Eclipse) by selecting your project, then calling from the context menu
Run as > Maven install
.
这篇关于如何使用Eclipse为Java项目创建pom.xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!