ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

maven私服nexus安装与基本使用

2021-01-30 17:29:04  阅读:233  来源: 互联网

标签:fastjson 8081 nexus jar 私服 maven 1.1


私服nexus安装

跳转:使用
安装第三方jar包到本地仓库和私服

  • 我采用的是压缩包安装安装,解压到无中文的目录
    在这里插入图片描述
  • 进入bin目录
    在这里插入图片描述
  • 启动命令提示符(以管理员身份)
    在这里插入图片描述
  • 切到对应的磁盘目录进行安装:nexus.bat intall
    在这里插入图片描述
  • 开启nexus.bat start
    在这里插入图片描述
  • 没有错误可以跳过, 如果出现The nexus service was launched, but failed to start.即启动失败
    ~\nexus-2.12.0-01\logs\wrapper.log中查看报错信息
    在这里插入图片描述
    我的报错是值这个类没有找到,查看其它大佬的博客传送门:The nexus service was launched, but failed to start. --nexus启动报错完美解决后发现是ClassNotFoundException异常。只需要这两个jar包即可:activation-1.1.1.jarjaxb-api-2.3.0.jar放入~\nexus-2.12.0-01\nexus\WEB-INF\lib即可重新启动
    在这里插入图片描述
  • 验证安装成功
    ~\nexus-2.12.0-01\conf\nexus.properties下,该文件里面有端口的描述,默认为8081,被占用可以kill或者修改端口
    验证网址:http://localhost:8081/nexus
    成功:默认-账号admin,密码admin123
    在这里插入图片描述
  • 图解:
    在这里插入图片描述
  • 指令
nexus.bat install #安装
nexus.bat uninstall #卸载
nexus.bat start #启动私服

私服使用

  • 上传私服
    ~/maven/conf/settings.xml中的servers标签中添加:(注意是maven)
<!-- 配置正式仓库账号密码、测试仓库账号密码 -->
 <server>
      <id>releases</id>
      <username>admin</username>
      <password>admin123</password>
    </server>

    <server>
      <id>snapshots</id>
      <username>admin</username>
      <password>admin123</password>
    </server>

需要上传的项目中的pom.xml文件:

<!-- 上传到私服 -->
<distributionManagement>
<!-- 私服正式库 -->
 <repository>
  <id>releases</id>
  <!-- http://localhost:8081/nexus/#view-repositories;public~configuration中你的正式库url -->
  <url>http://127.0.0.1:8081/nexus/content/repositories/releases/</url>
 </repository>
 <!-- 私服测试库 -->
 <snapshotRepository>
  <id>snapshots</id>
  <url>http://127.0.0.1:8081/nexus/content/repositories/snapshots/</url>
 </snapshotRepository>
</distributionManagement>

上传操作:maven生命周期的最后一站deploy(前面的操作本地仓库都会上传)

  • 下载操作
    ~/maven/conf/settings.xml中的profiles标签中添加:
<!-- 下载jar包配置 -->
<profile> 
 <!--profile的id -->
 <id>dev</id>
 <repositories>
  <repository> <!--仓库id,repositories可以配置多个仓库,保证id不重复 -->
   <id>nexus</id> <!--仓库地址,即nexus仓库组的地址 -->
   <url>http://localhost:8081/nexus/content/groups/public/</url> <!--是否下载releases构件 -->
   <releases>
    <enabled>true</enabled>
   </releases> <!--是否下载snapshots构件 -->
   <snapshots>
    <enabled>true</enabled>
   </snapshots>
  </repository>
 </repositories>
 <pluginRepositories> <!-- 插件仓库,maven的运行依赖插件,也需要从私服下载插件 -->
  <pluginRepository> <!-- 插件仓库的id不允许重复,如果重复后边配置会覆盖前边 -->
   <id>public</id>
   <name>Public Repositories</name>
   <url>http://localhost:8081/nexus/content/groups/public/</url>
  </pluginRepository>
 </pluginRepositories>
</profile>

激活在settings标签内:

<!-- dev与上面的下载的id对应上 -->  
<activeProfiles>
  <activeProfile>dev</activeProfile>
 </activeProfiles>
  • 测试
    通过上传后然后故意在本地仓库删掉对应依赖,从私服开始下载。
    在这里插入图片描述

安装第三方jar包到本地仓库和私服

  • 指令:以阿里巴巴的fastjson.jar为例,dos命令直接执行即可上传本地
----进入jar包所在目录运行
mvn install:install-file -DgroupId=com.alibaba -DartifactId=fastjson -Dversion=1.1.37 -Dfile=fastjson-1.1.37.jar -Dpackaging=jar
----打开cmd直接运行
mvn install:install-file -DgroupId=com.alibaba -DartifactId=fastjson -Dversion=1.1.37 -Dpackaging=jar -Dfile=jar包绝对路径

在这里插入图片描述

  • 私服上传第三方jar包
  • 指令:
--安装第三方jar包到私服
--在settings配置文件中添加登录私服第三方登录信息
<server>
<id>thirdparty</id>
<username>admin</username>
<password>admin123</password>
</server>
----进入jar包所在目录运行
mvn deploy:deploy-file -DgroupId=com.alibaba -DartifactId=fastjson -Dversion=1.1.37 -Dpackaging=jar -Dfile=fastjson-1.1.37.jar -Durl=http://localhost:8081/nexus/content/repositories/thirdparty/ -DrepositoryId=thirdparty
----打开cmd直接运行
mvn deploy:deploy-file -DgroupId=com.alibaba -DartifactId=fastjson -Dversion=1.1.37 -Dpackaging=jar -Dfile=jar包绝对路径 -Durl=http://localhost:8081/nexus/content/repositories/thirdparty/ -DrepositoryId=thirdparty

这里一定要注意DrepositoryId的值一定是和maven中配置的id对应上的
在这里插入图片描述
在这里插入图片描述

  • 上传成功~

标签:fastjson,8081,nexus,jar,私服,maven,1.1
来源: https://blog.csdn.net/qq_45593068/article/details/113434605

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有