本地搭建私服-nexus-maven-jar 对原创作者的细节完善,一个字一个字自己码的

9903端口

一、准备工作

 系统:LINUX

       JDK:已安装(未安装详见jdk安装教程:http://www.cnblogs.com/muzi1994/p/5818099.html)

       Maven:已安装(未安装详见maven安装教程:http://www.cnblogs.com/muzi1994/p/6030181.html)

       Nexus:

http://www.sonatype.org/nexus/go

       所有版本下载地址:

http://www.sonatype.org/nexus/archived/

       Nexus是一个强大的Maven仓库管理器,它极大地简化了自己内部仓库的维护和外部仓库的访问。

 

二、安装Nexus

1.解压nexus文件

 

 tar -zvxf nexus-2.12.0-01-bundle.tar.gz

 

  注:解压后有两个文件夹:

                  nexus-2.12.0-01: 是nexus的核心文件

                  sonatype-work :maven下载jar存放地址

2.启动Nexus

./bin/nexus start

默认情况下,不建议以root用户运行Nexus,可以修改bin/nexus中的配置跳过警告(修改RUN_AS_USER=root)

 vi bin/nexus

./bin/nexus start 重启

Nexus默认端口8081,如果想修改端口。修改/conf/nexus.properties文件

访问网址:http://YOUR-IP:PORT/nexus

  点击右上角的 Log In 按钮即可登陆了。默认登录账号/密码为: admin/admin123 ,登陆成功后的界面

点击Repositories,将列表中所有Type为proxy 的项目的 Configuration 中的 Download Remote Indexes 设置为True

 

将Releases仓库的Deployment Policy设置为 Allow ReDeploy

 

 

当然我们也避免不了会使用到一些第三方的 jar ,而这些jar包也不存在于互联网上的maven中央仓库中,这时我们可以手工添加jar 到我们的私服中。

添加第三方 jar 如下:

填写完必选字段,点击Upload Artifact(s)按钮即可。

上传odbc.jar

 

点击上传

 

 

查看上传的jar

 

 

3. 配置本地项目引用私服, 自动发布构件到远程仓库,在工程pom.xml中添加

这个ID需要与你的snapshots仓库的Repository ID一致

查看你的release,snapshots仓库地址

 

 

 

直接粘贴会报错,建议自己手打

<distributionManagement>

    <repository>

        <id>releases</id><!--这个ID需要与你的release仓库的Repository ID一致-->

        <url>http://20.2.11.9:9903/nexus/content/repositories/releases</url>

    </repository>

    <snapshotRepository>

        <id>snapshots</id><!--这个ID需要与你的snapshots仓库的Repository ID一致-->

        <url>http://20.2.11.9:9903/nexus/content/repositories/snapshots</url>

    </snapshotRepository>

</distributionManagement>

 

 

修改本地$MAVEN_HOME\conf目录下的settings.xml配置文件,添加如下配置

<servers>

    <server>

        <id>releases</id>

        <username>admin</username>

        <password>admin123</password>

    </server>

    <server>

        <id>snapshots</id>

        <username>admin</username>

        <password>admin123</password>

    </server>

</servers>

 

在本地工程目录下执行:你要确保你的项目能够正确启动,才能执行成功

mvn deploy

 

 

 

 

 

 

如此,我才发现我只是把我这个项目jar上传到私服,尴尬,我是想把所有的jar包上传啊

 

4.配置Maven从Nexus下载构件

在POM中配置Nexus私服,这样的配置只对当前的Maven项目有效。

<!--指定Nexus的构件仓库-->

<repositories>

    <repository>

        <id>public</id>

        <name>Team Maven Repository</name>

        <url>http://192.168.1.11:8081/nexus/content/groups/public/</url>

        <releases>

            <enabled>true</enabled>

        </releases>

        <snapshots>

            <enabled>true</enabled>

        </snapshots>

    </repository>

</repositories>

 

<!--指定Nexus的插件仓库-->

<pluginRepositories>

    <pluginRepository>

        <id>public</id>

        <name>Team Maven Repository</name>

        <url>http://192.168.1.11:8081/nexus/content/groups/public/</url>

        <releases>

            <enabled>true</enabled>

        </releases>

        <snapshots>

            <enabled>true</enabled>

        </snapshots>

    </pluginRepository>

</pluginRepositories>

在settings.xml中配置profile元素,这样就能让本机所有的Maven项目都使用自己的Maven私服。

<properties>

    <repository>

       <id>public</id>

        <name>Team Maven Repository</name>

       <url>http://192.168.1.11:8081/nexus/content/groups/public/</url>

       <releases>

         <enabled>true</enabled>

          </releases>

         <layout>default</layout>

         <snapshots>

         <enabled>true</enabled>

         </snapshots>

        </repository>

</properties>

 

 

 

致敬https://www.cnblogs.com/muzi1994/p/6026144.html

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值