前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >利用nexus搭建maven私服与本地jar安装到私服

利用nexus搭建maven私服与本地jar安装到私服

作者头像
用户5166330
发布2019-04-16 15:16:13
2.3K0
发布2019-04-16 15:16:13
举报
文章被收录于专栏:帅哥哥写代码帅哥哥写代码
引言

以前总感觉maven仓库很神秘。现在想想maven仓库其实就是提供了一个文件下载的服务器。把所有文件放到服务器上,通过“坐标”定位唯一一个文件进行下载。

正题

1.利用nexus搭建本地maven厂库

  1. 使用Maven deploy命令部署构建到Nexus上
nexus搭建

  • 下载nexus 去nexus官网来到下载页面,有几个系统版本,我这里选项windows。

下载页.png 解压之后

解压缩.png 在../nexus-3.13.0-01\bin目录下执行nexus.exe /run 可以修改../etc目录下nexus-default.properties文件,改变端口

配置信息.png 启动成功之后,输入http://localhost:8081/

nexus主页.png 右上角点击登录。默认用户名密码为admin/admin123。选择查看存储库列表

存储库列表.png 我这边新建了四个存储库

ysh存储库.png

ysh存储库.png

  • aliyun-maven

代理阿里云存储库.png 关键字type: proxy

  • ysh-group

组仓库存储.png 关键字type: group 成员:ysh-release、ysh-snapshot、aliyun-maven

  • ysh-release

ysh-release仓库仓储.png 关键字 type:hosted 版本策略 Release

  • ysh-snapshot

ysh-snapshot存储库.png 关键字 type:hosted 版本策略 Snapshot

建这四个存储库的目的:开发时直接使用group存储库,下载jar时,通过阿里云下载速度更快。ysh-release用于存储自己开发的稳定版jar、ysh-snapshot用于存储自己开发的测试版jar,目的都是为了共享自写的jar。

到此nexus搭建完成,并且完成初步分类建库。

本地jar安装到私服

  • 修改maven settings.xml配置如下
代码语言:javascript
复制
  <?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">
<localRepository>D:\maven\yshlocal</localRepository>
<pluginGroups>
</pluginGroups>
<proxies>
</proxies>
<servers>
 <server>      
   <id>ysh-release</id>  <!--此处id必须与eclipse中pom.xml配置的repository的id保持一致 -->     
   <username>admin</username>    
   <password>admin123</password>    
 </server>
 <server>      
     <id>ysh-snapshots</id> <!--此处id必须与eclipse中pom.xml配置的repository的id保持一致 -->      
     <username>admin</username>      
     <password>admin123</password>    
 </server>
</servers>
<mirrors>
 <mirror>
    <id>local maven</id>
    <mirrorOf>central</mirrorOf>
    <name>Local central</name>
    <url>http://localhost:8081/repository/ysh-group/</url>
 </mirror>
</mirrors>
<profiles>

 <profile>
  <id>dev</id> <!--此处id必须与acyiveProfiles标签中的值保持相同 -->
  <repositories>
    <repository>
      <id>local maven</id>
      <name>nexus</name>
      <url>http://localhost:8081/repository/ysh-group/</url>
       <releases>
          <enabled>true</enabled>          
       </releases>          
       <snapshots>           
          <enabled>true</enabled>          
       </snapshots>
    </repository>
  </repositories>
</profile>



</profiles>


<activeProfiles>
<activeProfile>dev</activeProfile>
</activeProfiles>
</settings>

  • 修改pom配置文件,添加如下配置
代码语言:javascript
复制
  <distributionManagement>
    <repository>
        <id>ysh-release</id>
        <name>user release version</name>
        <url>http://192.168.1.19:8081/repository/maven-releases/</url>
    </repository>
    <snapshotRepository>
        <id>ysh-snapshots</id>
        <name>user snapshots version</name>
        <url>http://127.0.0.1:8081/repository/maven-snapshots/</url>
    </snapshotRepository>
</distributionManagement>
<build>
    <defaultGoal>compile</defaultGoal>
    <finalName>page</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.18.1</version>
            <configuration>
                <skip>true</skip>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>
  • eclipse 选择run install,如下图

deploy.png

执行run命令

运行结果.png 因为我这里生成的是快照版jar。所以我们可以在ysh-snapshot存储库看到我安装到私服的jar,如下图

安装jar到私服.png

安装到私服后,通过坐标就可以下载我上传的jar了。

到此<<利用nexus搭建maven私服与本地jar安装到私服>>文章结束。

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018.10.11 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 引言
  • 正题
  • nexus搭建
  • 本地jar安装到私服
相关产品与服务
对象存储
对象存储(Cloud Object Storage,COS)是由腾讯云推出的无目录层次结构、无数据格式限制,可容纳海量数据且支持 HTTP/HTTPS 协议访问的分布式存储服务。腾讯云 COS 的存储桶空间无容量上限,无需分区管理,适用于 CDN 数据分发、数据万象处理或大数据计算与分析的数据湖等多种场景。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档