---
title: "maven的安装和nexus的安装"
author: "dou_shini8820"
date: "2012-11-13T23:26:06Z"
tags: []
categories: ["开源软件"]
slug: "maven-nexus"
draft: false
lastmod: "2013-02-19T18:29:21Z"
id: 1725191
url: "https://doushini.iteye.com/blog/1725191"
---

1、下载maven3，解压，添加环境变量MAVEN\_HOME和path

 

2、下载nexus2解压，添加环境变量path

 

3、把D:\\dev\\mvn\\apache-maven-3.0.4\\conf下的setting.xml中修改为&lt;localRepository&gt;H:\\MavenJar&lt;/localRepository&gt;，MavenJar是我的本地仓库

 

4、建立中央仓库，超级管理员身份运行cmd，执行nexus install

 

5、修改D:\\dev\\mvn\\nexus-2.1.2\\bin\\jsw\\conf中的wrapper.conf中wrapper.java.command=C:\\Program Files\\Java\\jdk1.6.0\_20\\bin

 

6、cmd中执行nexus start,然后浏览器中输入[http://localhost:8081/nexus/index.html#welcome](http://localhost:8081/nexus/index.html#welcome)

用户名admin，密码admin123

 

7、配置中央仓库：点击左侧的repository，复制Public Repositories他对应的地址：[http://localhost:8081/nexus/content/groups/public/](http://localhost:8081/nexus/content/groups/public/),即为中央仓库的地址

 

8、在parent的pom.xml中配置：

 &lt;repositories&gt;

```
   <repository>
      <id>nexus</id>
      <name>Nexus Repository</name>
      <url>http://localhost:8081/nexus/content/groups/public/</url>
      <layout>default</layout>
      <releases>
        <enabled>false</enabled>
      </releases>
   <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </repository>
  </repositories> 
```

 

9、配置镜像：设置私有工厂一般要配置镜像

在mvn的setting.xml中的&lt;mirrors&gt;里面添加：

 

```
<mirror>
   <id>central</id>
   <mirrorOf>*</mirrorOf>
   <name>Human Readable Name for this Mirror.</name>
   <url>http://localhost:8081/nexus/content/repositories/central</url>
  </mirror>
```

 

 这里面的\*表示parent的pom.xml中所有的repository添加配置，我的里面只有一个nexus

 

10、把lucence创建的nexus索引文件拷贝到D:\\dev\\mvn\\sonatype-work\\nexus\\indexer\\central-ctx中，先清空，也要先nexus stop。

 

 

 

二。maven创建项目

创建一个简单的maven项目的命令如下：

 

```
mvn archetype:create -DgroupId=com.luo -DartifactId=plat-DpackageName=com.luo -DarchetypeArtifactId=maven-archetype-artifactId=webapp
```

 

DpackageName可省略不写