springboot 工程集成Nexus私服仓库

2 篇文章 0 订阅

1.首先我们要下载apache-maven

官网下载地址:https://maven.apache.org/download.cgi
如果要下载历史版本,点击下图标记处:
在这里插入图片描述
apache-maven3.x历史版本
根据idea的版本下载对应的apache-maven版本(我用的对应版本:idea 2019,apache-maven-3.6.0)

2.设置idea maven使用刚下载的maven3.6.0

在这里插入图片描述
setting一定要用刚下载的maven里的setting文件

3.设置完idea,接下来配置apache-maven-3.6.0的setting文件

进入到apache-maven-3.6.0的conf目录
在这里插入图片描述
编辑setting文件

<?xml version="1.0" encoding="UTF-8"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->

<!--
 | This is the configuration file for Maven. It can be specified at two levels:
 |
 |  1. User Level. This settings.xml file provides configuration for a single user,
 |                 and is normally provided in ${user.home}/.m2/settings.xml.
 |
 |                 NOTE: This location can be overridden with the CLI option:
 |
 |                 -s /path/to/user/settings.xml
 |
 |  2. Global Level. This settings.xml file provides configuration for all Maven
 |                 users on a machine (assuming they're all using the same Maven
 |                 installation). It's normally provided in
 |                 ${maven.conf}/settings.xml.
 |
 |                 NOTE: This location can be overridden with the CLI option:
 |
 |                 -gs /path/to/global/settings.xml
 |
 | The sections in this sample file are intended to give you a running start at
 | getting the most out of your Maven installation. Where appropriate, the default
 | values (values used when the setting is not specified) are provided.
 |
 |-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 http://maven.apache.org/xsd/settings-1.2.0.xsd">
  
  <pluginGroups></pluginGroups>

  <proxies></proxies>

  <servers>
    <server>
        <id>nexus-releases</id>
        <username>admin</username>
        <password>cloud#123</password>
    </server>
    <server>
        <id>nexus-snapshots</id>
        <username>admin</username>
        <password>cloud#123</password>
    </server>
  </servers>

  <mirrors>
    <mirror>
      <id>nexus-releases</id>
      <mirrorOf>*</mirrorOf>
      <url>http://172.16.2.89:8081/repository/maven-public/</url>
    </mirror>
    <mirror>
      <id>nexus-snapshots</id>
      <mirrorOf>*</mirrorOf>
      <url>http://172.16.2.89:8081/repository/maven-snapshots/</url>
    </mirror>
  </mirrors>

  
  <profiles>
    
  </profiles>

  <activeProfiles>
    
  </activeProfiles>
</settings>

4.配置springboot工程的pom.xml文件

<!-- 告诉Maven可以从这个仓库下载releases和snapshots版本的jar包 -->
<repositories>
    <repository>
        <id>nexus-releases</id>
        <url>http://172.16.2.89:8081/repository/maven-public/</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>

// id 一定要跟setting.xml文件里server的id一致
<!-- 上传本地jar到Nexus私服 -->
<distributionManagement>
    <repository>
        <id>nexus-releases</id>
        <name>Releases</name>
        <url>http://172.16.2.89:8081/repository/maven-public/</url>
    </repository>
    <snapshotRepository>
        <id>nexus-snapshots</id>
        <name>Snapshot</name>
        <url>http://172.16.2.89:8081/repository/maven-snapshots/</url>
    </snapshotRepository>
</distributionManagement>

5.集成完毕,执行maven clean install,推送到Nexus执行maven deploy

在这里插入图片描述

6.推送成功,在Nexus查看jar

在这里插入图片描述

在这里插入图片描述

7.springboot工程pom文件引入

<dependency>
    <groupId>com.xxx</groupId>
    <artifactId>common-server</artifactId>
    <version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
    <groupId>com.xxx</groupId>
    <artifactId>cache-server</artifactId>
    <version>1.0.0-SNAPSHOT</version>
</dependency>

8.Reimport即可

在这里插入图片描述

9.本地仓库

在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值