1.首先我们要下载apache-maven
官网下载地址:https://maven.apache.org/download.cgi
如果要下载历史版本,点击下图标记处:
根据idea的版本下载对应的apache-maven版本(我用的对应版本:idea 2019,apache-maven-3.6.0)
2.设置idea maven使用刚下载的maven3.6.0
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>