docker搭建nexus3私库上传下载jar

查看docker上的nexus3

docker search nexus3

 

拉取镜像

docker pull sonatype/nexus3

 

启动Nexus3的容器

 

查看启用情况

访问Nexus界面

http://x.x.x.x:8081  

登录Nexus页面

默认用户名/密码:admin/admin123

 


 

环境装好以后,自带的中央仓库的代理

也可以自己增加增加新的代理源

创建代理,这里有类型可以选择。

Group是组,可以加入其它代理或本地仓库

Proxy是代理类型,可以添加的其它的代理源。

Hosted 是可以创建自己的本地仓库。



按自己个人需要增加常用的一些的代理推荐:

1. aliyun

http://maven.aliyun.com/nexus/content/groups/public

2. apache_snapshot

https://repository.apache.org/content/repositories/snapshots/

3. apache_release

https://repository.apache.org/content/repositories/releases/

4. atlassian

https://maven.atlassian.com/content/repositories/atlassian-public/

5. central.maven.org

http://central.maven.org/maven2/

6. datanucleus

http://www.datanucleus.org/downloads/maven2

7. maven-central (安装后自带,仅需设置Cache有效期即可)

https://repo1.maven.org/maven2/

8. nexus.axiomalaska.com

http://nexus.axiomalaska.com/nexus/content/repositories/public

9. oss.sonatype.org

https://oss.sonatype.org/content/repositories/snapshots

10.pentaho

https://public.nexus.pentaho.org/content/groups/omni/

 

强调一下,在

How long (in minutes) to cachemetadata before rechecking the remote repository.

统一设置为

288000 200天,当然可以设置为更长的时间

设置maven-public

将这些代理加入Group

 

完成这些步骤之后,就可设置本地mavenseting.xml        文件。没有自己设置的情况下,一般默认值在

 

mirrors节点下加入如下配置

 <mirrors>

  <mirror>

     <id>nexus</id>

     <mirrorOf>central</mirrorOf>这里的可以填*也可以填central,推荐填central先从私库下载,*代表所有,不同版本感觉有差异。

     <name>internal nexus repository</name>

     <url>http://172.16.6.31:8081/repository/maven-public/</url>这一段配置,描述的便是 上一步中提到的那个Public Reposiories的信息,这个地址便是他的地址,这些写都可以再界面上看到

   </mirror>这里的是localhost是在本机搭建测试用的,如果是公司内部的仓库的话,可自行修改成公司内网ip地址。

 </mirrors>

找的sever节点

        <server>

     <id>nexus</id> id的填写不重要,随便取,后面上传的时候会用到

     <username>admin</username>

     <password>admin123</password>

   </server>

       

找到 <profiles> 标签,添加仓库信息:

<profile>

 <id>nexus</id>

 <!--Enable snapshots for the built in central repo to direct -->

 <!--all requests to nexus via the mirror -->

 <repositories>

   <repository>

     <id>central</id>

     <url>http://central</url>

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

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

   </repository>

 </repositories>

 <pluginRepositories>

   <pluginRepository>

     <id>central</id>

     <url>http://central</url>

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

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

   </pluginRepository>

 </pluginRepositories>

</profile>

激活仓库:

<activeProfiles>

 <!--make the profile active all the time -->

 <activeProfile>nexus</activeProfile>

</activeProfiles>

 

在工程目录下,运行命令:mvn clean package


能看到从私库上面下载我们需要的jar


上传jar文件到我们私库上面。

第一种可以使用我们的命令行的方式,进行上传。

 

mvn deploy:deploy-file -DgroupId=com.maxnerva-DartifactId=domo-comsumer -Dversion=1.0.0 -Dpackaging=jar-Dfile=D:\task\demo-parent\demo-comsumer\target\demo-comsumer-1.0-SNAPSHOT.jar -Durl=http://172.16.6.31:8081/repository/maxnerva/  -DrepositoryId=nexus

 

参数说明

DgroupIdDartifactIdDversion——表示的是构建坐标

Dpackaging——表示的是上传的包的类型,一般为jar,不用改变,根据你的实际情况来改变。

Dfile——表示的是你需要上传的包的地址

Durl——表示的是你要上传到的私有仓库的地址

DrepositoryId——表示你的身份信息,可以从第二步获取。

 

 

也可以通过的我们界面进行上传

 

 

按照要求填写,输入自己的groupid  artifactIdversion。即可上传

 

 

可查看到上传成功到私库上的jar。

 

Idea配置的maven可以自己通过idea远程部署。

 

 

配置的pom.xml文件

pom文件添加如下,这里的seting.xml文件id上面的id要对应,name无所谓

 

 

<distributionManagement>
    <repository>
        <id>nexus</id>
        <name>Nexus ReleaseRepository</name>
       <url>http://172.16.6.31:8081/repository/maxnerva/</url>
    </repository>
</distributionManagement>

 

如果是deploy出现问题,那么可能是因为将部署路径写错,错误在于将SNAPSHOT版本写成RELEASE版本查看一下私库的版本

 

Snapshot版本代表不稳定、尚处于开发中的版本,快照版本。

Release版本则代表稳定的版本,发行版本。

 

 

根据自己项目的类型,进行设置私库的版本类型

  

双击,即可完成部署。


 

 

从私库上面下载我们上传上去的jar文件,

 

配置依赖

 

 

下载成功。


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值