1

我有 Eclipse: eclipse-jee-juno-win32。我需要用它创建 Maven 项目,但问题是,我一直在寻找如何安装 maven 插件或其他东西,我可以创建 maven 项目。不幸的是我什么也找不到。

任何人都可以向我提供一些如何在 Eclipse 中创建 Maven 项目的信息吗?以前我一直在使用 IntelliJ,但现在我需要使用 Eclipse,这是我第一次运行它。

4

5 回答 5

7

I have been using Maven for some time now and a very easy way to use it in Eclipse is:

  1. Open Eclipse and go to: Help / Eclipse Marketplace
  2. Insert on search: "Maven" and look for "Maven Integration for Eclipse WTP" and install it
  3. If the installation was successfully made you should see in Window/Preferences the Maven option in the left.
  4. After this I would advice you to download the last version from here: http://maven.apache.org/download.html and put it on a folder in C partition(or other partitions) - just remember that the path to the downloaded maven shouldn't contain spaces (you will have errors) - for example, my path is: "c:\Apache_Maven\apache-maven-3.0.4..."
  5. When you download it, go in Eclipse -> Window -> Preferences -> Maven (from left menu and expand it) -> Installations -> and add you path to the downloaded maven.
  6. To create the project: New -> Other -> Maven -> Maven Project -> and search on filter the archetype you would like to use (for example: use maven-archetype-webapp for web application etc.). Click Next and put your project details: Group Id, Artifact Id, Version etc.
  7. When you finished creating the project, the most important file is pom.xml. There you add your dependencies. Another important thing, your maven local repository will be created here: "c:\Users\YOUR_USERNAME\m2."
  8. If you want to run maven install/build/clean etc, you right click on project and click "Run as" -> Select option

I hope these steps will help you start working with Maven. :)

于 2012-07-23T21:49:12.500 回答
2

您有 2 个选项。

  1. 在 Eclipse 中,打开 Help/Eclipse Marketplace,然后编写 maven。您将看到 Eclipse 的 maven 集成。我不喜欢它,因为在我的工作中,我们的项目太大了。但如果你有一些小东西,它可能是最好的选择。

  2. 使用 WTP 插件手动构建。添加到您的 pom.xml:

pom.xml:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-eclipse-plugin</artifactId>
    <configuration>
      <wtpapplicationxml>true</wtpapplicationxml>
      <wtpversion>2.0</wtpversion>
    </configuration>
  </plugin>

然后在你的根目录中(pom.xml 存在的地方)

mvn eclipse:clean eclipse:eclipse

它创建所有 Eclipse 结构(所有 jar 都包含在您的项目中)。然后您只需要将现有项目导入工作区:文件/导入/常规/现有项目到工作区,选择您的项目目录

于 2012-07-23T20:26:23.060 回答
0

我至少知道两种方法:
1.安装eclipse maven插件m2eclipse:Help->Intall new software:使用:http: //download.eclipse.org/technology/m2e/releases [enter]
2.执行mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart。这将创建基本的 Maven 项目结构。然后,在生成 pom.xml 的文件夹中执行: mvn eclipse:eclipse
您还可以执行mvn archetype:generate并从数百个预定义的项目类型(archietypes)中选择一种

于 2012-07-23T20:34:20.020 回答
0

您可以下载Springsource Tool Suite (STS) 并创建模板 maven 项目。

于 2012-07-23T20:37:20.017 回答
0

您还可以安装 JBoss Tools,它为 JSF、Seam、Spring 等各种原型设置了 Maven 插件。如果您使用的是 Indigo,请选择 JBoss Tools 3.3 Final;对于 Juno,请选择 JBoss Tools 3.7 或 4

于 2013-02-08T15:38:40.833 回答