首页 > 其他 > 详细

Maven+Nexus安装配置

时间:2020-06-12 22:11:30      阅读:77      评论:0      收藏:0      [点我收藏+]

 

Maven+Nexus安装配置

环境准备

 jdk1.7+环境 可以通过

>java -version查看java环境

 

nexus2安装部署

 下载及安装nexus2

 1. 下载nexus:

技术分享图片

  2. 解压安装包,会生成两个文件夹

技术分享图片

  3. 设置环境变量NEXUS_HOME和PATH

  技术分享图片

    Path=%NEXUS_HOME%\bin

 4. 以管理员身份打开cmd,安装nexus(>nexus install),启动(>nexus start

 (win10:开始>Windows系统>命令提示符>右击“以管理员身份运行”)

技术分享图片

  5. 打开网站http://localhost:8081/nexus/,登录admin/admin123

  技术分享图片

  *nexus2安装成功!

 nexus2导入本地maven库

 注:Repository类型:

  •   group类型:即组中可以包含多个nexus库
  •   hosted类型:引入第三方jar库
  •  proxy类型

 1. 在admin登录状态下,Repositories中会有默认的几个库:

  技术分享图片

  2. 找到本地库位置(此处以IF库为例),将本地库内所有文件拷贝到nexus中

 [Nexus安装目录]\sonatype-work\nexus\storage\[要导入的库名,如‘central]

 3. 刷新nexus管理器,在Browse Storage中会有拷贝的本地库文件

  技术分享图片

  *nexus本地maven库导入成功!

 nexus2第三方jar导入

 使用默认的“3rd party”库,步骤如图,添加所需jar包

  技术分享图片

  * Nexus2第三方jar导入成功!

 nexus2添加group组

 1. 添加group组,(group类型:即组中可以包含多个nexus库)

  技术分享图片

  2.配置Repository

  技术分享图片

  *添加group成功!

 Maven配置连接私服

 Maven安装配置

 1. 下载maven安装包,并解压

技术分享图片

 

 

 2. 配置maven环境,Maven_HOME和PATH

技术分享图片

技术分享图片

 

 

 

 3. Cmd查看maven配置成功,>mvn -v

 技术分享图片

 

 

 *maven配置成功!

 Maven配置本地仓库及私服

 1. 打开$Maven_path/conf/settings.xml 文件,配置相关内容

 技术分享图片

 

 

 设置本地仓库<localRepository>

 2. 配置<server>

<servers>

  <server>  

          <id>bigdata</id>   #Id:私服的唯一键

          <username>admin</username>     #Username:登录nexus管理界面的用户名

          <password>admin123</password>    #Password:登录nexus管理界面的密码

  </server>

</servers>

3. 配置<mirror>

<mirror>

      <id>nexus</id>

      <mirrorOf>*</mirrorOf>      #mirrirOf:*为过滤全部

      <url>http://172.16.15.126:8081/nexus/content/groups/sunyard/</url>    #url:到私服的地址,即nexus库的地址

</mirror>

 技术分享图片

 

 

4. 设置<profile>

<profile>

    <id>nexus</id>

    <repositories>

    <repository>

             <id>bigdata</id>

             <url>http://172.16.15.126:8081/nexus</url>

             <releases><enabled>true</enabled><updatePolicy>always</updatePolicy></releases>

      <snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots>

    </repository>

    </repositories>

    <pluginRepositories>

              <pluginRepository>

            <id>bigdata</id>

            <url>http://172.16.15.126:8081/nexus</url>

            <releases><enabled>true</enabled></releases>

            <snapshots><enabled>true</enabled></snapshots>

    </pluginRepository>

    </pluginRepositories>

</profile>

5. 设置<activeProfiles>

<activeProfiles>

        <activeProfile>nexus</activeProfile>

</activeProfiles>

*完成私服的配置!

常见错误

对于私服Maven包下载不全

1. 本地仓库中相应文件夹中是否有此jar包,一般对于本成功的下载,本机仓库会有会在{MAVEN_repo}/{groupid}/{artifactid}/{version}路径下面生成 *.lastUpdated 文件。

2. 查看Nexus中是否有此jar包

 ①   如果没有,则调整setting.xml文件的下载路径,改为从全球仓库中下载;下载完成后本地库会自动更新到私服中(注意:此时可能有一个网络的问题,下载全球包的网络和私服的网络不是一个网络,即,对于公司建的私服ip是内网的,由于公司网络有时链接不上全球库,所以可能会切换非公司内网,这时链接外网时是无法链接到私服的,所以可能会存在无法同步更新的问题,解决:全球仓库下载完手动添加私服的相关包,步骤如“nexus2导入本地maven库”

 ②   如果有,则删除*.lastUpdated 文件重新Maven upload重新下载,重新下载还不成功,则检查私服访问路径是否有错

 

* 将外部jar打入本地maven仓库

 1.在path中配置maven环境变量到 …/bin目录

 2.cmd中执行>mvn install:install-file -Dfile= fink-deppendencies-1.0.0.jar -DgroupId=com.sunyard -DartifactId=fink-deppendencies -Dversion=1.0.0 -Dpackaging=jar

 3.在pom.xml中加入包信息

<dependency>

    <groupId>com.sunyard</groupId>

    <artifactId>fink-deppendencies</artifactId>

    <version>1.0.0</version>

</dependency>

 

 

 

 

 

Maven+Nexus安装配置

原文:https://www.cnblogs.com/xin-xing/p/13110287.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!