用Eclipse构建Maven项目

时间:2024-04-14 23:59:03

Eclipse中m2eclipse插件的安装

Help>Install New Software

用Eclipse构建Maven项目

Click Add

Name: m2e

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

用Eclipse构建Maven项目

Click OK

用Eclipse构建Maven项目

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

用Eclipse构建Maven项目

Click Add and add the installation home of maven

用Eclipse构建Maven项目

Click Finish choose the item

用Eclipse构建Maven项目

Click Apply and OK

  2. 设置自定义本地仓库

Open settings.xml

用Eclipse构建Maven项目

修改默认的本地仓库位置

<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”目录下

用Eclipse构建Maven项目

Window>Preferences

用Eclipse构建Maven项目

Create a new maven project

用Eclipse构建Maven项目

Choose maven-archetype-webapp

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

用Eclipse构建Maven项目

Group Id: 基本包名

Artifact Id: 项目名

用Eclipse构建Maven项目

用Eclipse构建Maven项目