速建maven Nexus私服环境(重要步骤)

 步骤一.

https://www.sonatype.com/download-oss-sonatype在此路径下载,将下载的zip文件解压,解压zip文件时路径不要有中文,否则报错。

步骤二.

1.在path路径下配置Nexus环境变量。

2.安装服务和启动服务,以管理员身份运行cmd命令,安装服务 nexus/install NexusService(自定义服务名称),启动服务 nexus/start NexusService。

3.登陆nexus,默认端口8081,通过网址 http//localhost:8081进入Nexus控制台界面,sign in登陆,默认密码在 nexus-3.30.1-01-win64\sonatype-work\nexus\admin.password文件中。重置密码,禁用匿名访问,成功登陆,登陆后查看日志,看是否有异常并修复。

4.Nexus自带仓库

hosted本地仓库用于部署自己公司或者自己的jar组件
proxy代理仓库用于远程代理的公共仓库,比如代理阿里云的maven仓库
group仓库组用于合并多个hosted/proxy仓库,操作多个仓库只需要引用一个group即可。

5.创建自己的仓库,hosted类型(存储自己jar文件),proxy类型(将远程仓库jar包下到本地,从阿里云下载的话是 hhtp://maven.aliyun.com/nexus/content/groups/public/),group类型(聚合类型仓库,可将前面两个类型聚合成一个URL对外提供服务,属于仓库集合)

步骤三:

1.将setting.xml配置文件中的第三方Maven镜像站全部注释掉,Nexus有相同作用,在此配置文件中添加如下代码。

<mirror>
   <id>mynexus</id>
   <name>mynexus</name>
   <url>http://localhost:8081/repository/maven-group/</url>
   <mirrorOf>*</mirrorOf>  //*代表对远程仓库所有请求都转至该镜像
</mirror>

2.配置账号密码,仍然在setting.xml中

<server>
    <id>mynexus</id>  //与<mirror>标签中id一致
    <username>admin</username>
    <password>xxxxxxxxxxxxx</password>
</server>

3.开启SNAPSHOT版本支持(官方默认不支持下载SNAPSHOT版本的jar,所以默认位RELEASE版本的依赖),依旧在setting.xml中配置。

<profiles>
    <profile>
        <id>nexus</id>
        <repositories>
            <repository>
                <id>mynexus</id>
                <name>Nexus</name>
                <url>http://localhost:8081/repository/maven-group/</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </repository>
        </repositories>
        <pluginRepositories>
            <pluginRepository>
                <id>mynexus</id>
                <name>Nexus</name>
                <url>http://localhost:8081/repository/maven-group/</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </pluginRepository>
        </pluginRepositories>
    </profile>
</profiles>
<activeProfiles>
    <activeProfile>nexus</activeProfile>
</activeProfiles>

4.创建测试项目(创建maven-archetype-quickstart项目,quickstart代表速成项目,省去手动创建项目结构和配置文件的步骤,或者mvn archetype:generate 命令使用 Maven 快速创建一个新的项目。创java类并执行depoly进行部署,测SNAPSHOT或者RELEAS其中一个版本即可),还需在pom.xml中添加如下代码,否则将报错。

<distributionManagement>
    <repository>
        <id>mynexus</id>
        <name>Nexus Release Repository</name>
        <url>http://localhost:8081/repository/maven-releases/</url>
    </repository>
    <snapshotRepository>
        <id>mynexus</id>
        <name>Nexus Release Repository</name>
        <url>http://localhost:8081/repository/maven-snapshots/</url>
    </snapshotRepository>
</distributionManagement>

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值