用Eclipse构建Maven项目

Eclipse中m2eclipse插件的安装

Help>Install New Software

Click Add

Name: m2e

Location: http://download.eclipse.org/technology/m2e/releases

Click OK

It seems that the plug-in has already been installed in this version of eclipse. If not, just click next until the last and restart eclipse.

Configuration:

  1. 绑定maven的安装目录

Window>Preferences

Click Add and add the installation home of maven

Click Finish choose the item

Click Apply and OK

  2. 设置自定义本地仓库

Open settings.xml

修改默认的本地仓库位置

<localRepository>F:/m3/repository</localRepository>

修改默认的中央仓库镜像

<mirrors>
    <!-- mirror
     | Specifies a repository mirror site to use instead of a given repository. The repository that
     | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
     | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
     |
    <mirror>
      <id>mirrorId</id>
      <mirrorOf>repositoryId</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://my.repository.com/repo/path</url>
    </mirror>
     -->
    <mirror>
      <id>ibiblio</id>
      <mirrorOf>central</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://mirrors.ibiblio.org/maven2/</url>
    </mirror>
  </mirrors>

保存所做的修改,同时还需要把这个settings.xml文件复制一份到“F:/m3”目录下

Window>Preferences

Create a new maven project

Choose maven-archetype-webapp

如果这一步出错了,请参考 http://jingyan.baidu.com/article/63acb44ad96e4b61fcc17ecf.html

Group Id: 基本包名

Artifact Id: 项目名

原文地址:https://www.cnblogs.com/wqsbk/p/4890303.html