一、简单介绍
二、私有仓库依赖上传
1、在maven(本文是用的3.8.5的)的settings.xml的servers节点下新增以下配置
<server>
<id>maven-snapshots</id>
<username>>nexus的snapshots库用户名没有就用登录名admin</username>
<password>nexu的snapshots密码</password>
</server>
<server>
<id>maven-releases</id>
<username>nexus的releases库用户名没有就用登录名admin</username>
<password>可以是一个密码</password>
</server>
2、在上传的依赖项目的pom的project节点下新增以下配置
<!-- 发布项目的时候有用 deploy-->
<distributionManagement>
<snapshotRepository>
<id>maven-snapshots</id>
<url>http://私仓的ip端口或域名/repository/maven-snapshots/</url>
</snapshotRepository>
<repository>
<id>maven-releases</id>
<url>http://私仓的ip端口或域名/repository/maven-releases/</url>
</repository>
</distributionManagement>
3、清理下项目或者complile或者package一下最后运行deploy(也可以直接运行deploy)
4、在上传后的效果展示
三、私有仓使使用
1、在maven的settings中添加
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<!--
<localRepository>/home/maven/repository</localRepository>
-->
<localRepository>L:\abc\utils\m1</localRepository>
<!--Maven是否需要和用户交互以获得输入。如果Maven需要和用户交互以获得输入,则设置成true,反之则应为false。默认为true。 -->
<interactiveMode>true</interactiveMode>
<!--Maven是否需要使用plugin-registry.xml文件来管理插件版本。 -->
<!--如果设置为true,则在{user.home}/.m2下需要有一个plugin-registry.xml来对plugin的版本进行管理 -->
<!--默认为false。 -->
<usePluginRegistry>false</usePluginRegistry>
<!--表示Maven是否需要在离线模式下运行。如果构建系统需要在离线模式下运行,则为true,默认为false。 -->
<!--当由于网络设置原因或者安全因素,构建服务器不能连接远程仓库的时候,该配置就十分有用。 -->
<offline>false</offline>
<!--当插件的组织Id(groupId)没有显式提供时,供搜寻插件组织Id(groupId)的列表。 -->
<!--该元素包含一个pluginGroup元素列表,每个子元素包含了一个组织Id(groupId)。 -->
<!--当我们使用某个插件,并且没有在命令行为其提供组织Id(groupId)的时候,Maven就会使用该列表。 -->
<!--默认情况下该列表包含了org.apache.maven.plugins和 org.codehaus.mojo -->
<!--
<pluginGroups>
<pluginGroup>org.mortbay.jetty</pluginGroup>
<pluginGroup>org.codehaus.cargo</pluginGroup>
<pluginGroup>com.hundsun.scm.maven.plugins</pluginGroup>
<pluginGroup>org.apache.maven.plugins</pluginGroup>
<pluginGroup>org.codehaus.mojo</pluginGroup>
</pluginGroups>
-->
<!--用来配置不同的代理,多代理profiles可以应对笔记本或移动设备的工作环境:通过简单的设置profile id就可以很容易的更换整个代理配置。 -->
<proxies>
<!--代理元素包含配置代理时需要的信息
<proxy>
代理的唯一定义符,用来区分不同的代理元素。
<id>myproxy</id>
该代理是否是激活的那个。true则激活代理。当我们声明了一组代理,而某个时候只需要激活一个代理的时候,该元素就可以派上用处。
<active>true</active>
代理的协议。 协议://主机名:端口,分隔成离散的元素以方便配置。
<protocol>http://…</protocol>
代理的主机名。协议://主机名:端口,分隔成离散的元素以方便配置。
<host>proxy.somewhere.com</host>
代理的端口。协议://主机名:端口,分隔成离散的元素以方便配置。
<port>8080</port>
代理的用户名,用户名和密码表示代理服务器认证的登录名和密码。
<username>proxyuser</username>
代理的密码,用户名和密码表示代理服务器认证的登录名和密码。
<password>somepassword</password>
不该被代理的主机名列表。该列表的分隔符由代理服务器指定;例子中使用了竖线分隔符,使用逗号分隔也很常见。
<nonProxyHosts>*.google.com|ibiblio.org</nonProxyHosts>
</proxy>
-->
</proxies>
<servers>
<server>
<id>maven-snapshots</id>
<username>用户名</username>
<password>密码</password>
</server>
<server>
<id>maven-releases</id>
<username>用户名</username>
<password>密码</password>
</server>
</servers>
<!-- maven 默认的中央仓库 -->
<!--
<repositories>
<repository>
<id> central</id>
<name> Maven Repository Switchboard</name>
<layout> default</layout>
<url> http://repo1.maven.org/maven2</url>
<snapshots>
<enabled> false</enabled>
</snapshots>
</repository>
</repositories>
-->
<!-- 镜像仓库,将releases snapshots thirdparty的jar同步到一起-->
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>public</id>
<name>morik</name>
<mirrorOf>*</mirrorOf>
<url>http://您的仓库地址ip端口或域名/repository/maven-public/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>jdk-1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
<!-- maven开发库 -->
<profile>
<id>dev</id>
<repositories>
<repository>
<id>maven-releases</id>
<url>http://您的仓库地址ip端口或域名/repository/maven-releases/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>maven-snapshots</id>
<url>http://您的仓库地址ip端口或域名/repository/maven-snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>dev</activeProfile>
</activeProfiles>
</settings>
2、新建maven项目引入依赖包测试
3、效果(查看下基础环境common集成的nacos、sentinel、日志、链路追踪等)