需要已经在nexus中创建了Maven私服,确保托管资源库中已经有需要拉取的jar包。
一、Linux 安装Nexus3.42.0-01图文教程
二、nexus创建Maven私服图文教程
三、使用nexus上传jar包图文教程
四、IDEA Maven项目上传jar包到nexus仓库图文教程
配置Apache Maven的目的是为了使用仓库管理,而不是默认使用中央仓库。
在Maven的settiing.xml中添加一个镜像配置,并覆盖中央仓库的默认配置。
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/SETTINGS/1.0.0">
<localRepository>F:\maven\apache-maven-3.6.1\reponsitorylocalRepository>
<servers>
<server>
<id>nexusid>
<username>adminusername>
<password>adminpassword>
server>
servers>
<mirrors>
<mirror>
<id>nexusid>
<name>nexus repositoryname>
<url>http://t-test.dmsd.tech:8089/repository/test_group/url>
<mirrorOf>centralmirrorOf>
mirror>
mirrors>
settings>

2.1 在nexus的托管仓库中查看需要拉取jar包的坐标,注意组资源库中能够查看所有托管资源库和代理资源库中的jar包



<dependency>
<groupId>tk.mybatisgroupId>
<artifactId>mapper-spring-boot-starterartifactId>
<version>2.1.5version>
dependency>
添加依赖之后的pom.xml结构
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0modelVersion>
<groupId>org.examplegroupId>
<artifactId>apcheMavenartifactId>
<version>1.0-SNAPSHOTversion>
<properties>
<maven.compiler.source>11maven.compiler.source>
<maven.compiler.target>11maven.compiler.target>
properties>
<dependencies>
<dependency>
<groupId>com.wangweigroupId>
<artifactId>springtestartifactId>
<version>1.0.0version>
dependency>
<dependency>
<groupId>tk.mybatisgroupId>
<artifactId>mapper-spring-boot-starterartifactId>
<version>2.1.5version>
dependency>
dependencies>
project>







至此IDEA 中使用maven从nexus中下载jar包已经结束。