maven私服的搭建及jar包上传下载

来源:互联网 发布:ubuntu复制文件到win 编辑:程序博客网 时间:2024/06/05 15:29

私服就是公司私自使用的服务器

搭建私服的步骤

          前提:必须有jdk和java_home环境变量.

1.下载私服软件

              地址:https://www.sonatype.com/download-oss-sonatype


2.下载好后解压到一个非空的文件夹下

3.用管理员身份运行cmd.

4.复制新解压后nexus的bin目录路径


5.在cmd窗口中运行命令: 

   (1)进入bin目录


(2)执行nexus install进行安装.此时可以在服务中看到nexus服务.是已停止状态.

(3)还是在bin目录下运行nexusstart 启动该服务.

6.私服管理

       在...\nexus-2.14.5-02-bundle\nexus-2.14.5-02\conf目录下找到nexus.properties文件

   

   

访问:http://localhost:8081/nexus   ---->点击右上角“log in”---->输入username:admin 和Password:admin123登录

7.利用maven下载jar包

   在maven软件中把私服地址配置上.在settings.xml中找到profiles节点进行配置一下代码

<profiles>   <profile> <id>dev</id> <repositories> <repository>  <!--仓库id,可以配置多个仓库要保证id不重复--> <id>nexus</id> <!--仓库地址,也就是我们私服的仓库组地址--> <url>http://localhost:8081/nexus/content/groups/public/</url> <!--是否下载releases版本的jar--> <releases> <enabled>true</enabled> </releases> <!--是否下载snapshots版本的jar-->  <snapshots>  <enabled>true</enabled>  </snapshots> </repository> </repositories> <pluginRepositories>  <!--插件仓库,maven运行时的命令依赖的插件jar包,也从私服下载--> <pluginRepository> <id>public</id> <url>http://localhost:8081/nexus/content/groups/public/</url> </pluginRepository> </pluginRepositories> </profile>      </profiles>

8.上传jar包

   (1)把自己的包传到私服里,需要配置账号,就是我们开始用的admin/admin123

   (2)在maven软件的配置文件settings.xml里找到server节点进行设置.

<!-- 设置发布时的用户名 --> <servers><!-- releases和snapshots表示是上传到正式仓库还是开发仓库 --><server><id>releases</id><username>admin</username><password>admin123</password></server><server><id>snapshots</id><username>admin</username><password>admin123</password> </server> </servers>

(3)在项目的父项目的pom.xml中增加上传的仓库地址

<!-- 依赖包发布到私服,将开发的包上传到宿主仓库 --><distributionManagement><!-- 上传到宿主仓库的releases --><repository><id>releases</id><name>Internal Releases</name><url>http://localhost:8081/nexus/content/repositories/releases/</url></repository><!-- 上传到宿主仓库的snapshots --><snapshotRepository><id>snapshots</id><name>Internal Snapshots</name><url>http://localhost:8081/nexus/content/repositories/snapshots/</url></snapshotRepository></distributionManagement>

(4)运行deploy.