Maven本地仓库nexus配置与使用

1、主页登录:http://localhost:8081/nexus/

2、用户登录 默认:admin 密码:admin123

3、Views/Respositories选择Respositories

找到Central:

找到Public Repositories!!!!注意:左边是可以聚合的仓库!!!!

4、配置hosted repositor

5、配置用户密码 
在Security-->Users中配置,在deployment用户上点击右键,选择Set Password,然后设置一个密码,做这个操作是为了后面提交做准备 
6、在用户机器上配置settings.xml 
<?xml version="1.0" encoding="UTF-8"?>

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
 
  <servers>
  
      <server>
          <id>nexus-snapshots</id>
          <username>deployment</username>
          <password>deployment</password>
      </server>

  </servers>
  
  <mirrors>
  
      <mirror>
          <id>nexus</id>
          <name>internal nexus repository</name>
          <url>http://localhost:8081/nexus/content/groups/public/</url>
          <mirrorOf>central</mirrorOf>
      </mirror>
      
  </mirrors>
  
</settings>
    

7、配置maven项目的pom文件

 1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 2     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 3 
 4     <modelVersion>4.0.0</modelVersion>
 5     <groupId>my.work</groupId>
 6     <artifactId>newlife</artifactId>
 7     <version>0.0.1-SNAPSHOT</version>
 8     <packaging>war</packaging>
 9     <name />
10     <!-- 配置部署的远程仓库 -->
11     <distributionManagement>
12         <snapshotRepository>
13             <id>nexus-snapshots</id>
14             <name>nexus distribution snapshot repository</name>
15             <url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
16         </snapshotRepository>
17     </distributionManagement>
18 </project>

8、添加本地jar文件

例如在Releases添加本地jar:

选择GAV方式,上传本地jar文件,更新Browse Index,在项目的pom.xml文件中直接引用相应的Artifact。

posted @ 2013-10-21 11:25  prison  阅读(1226)  评论(0编辑  收藏  举报