安装nexus maven私服
下载
资源
阿里云和硬盘
nexus-3.30.0-01-win64.zip
安装路径
E:\Program Files (x86)\nexus\nexus-3.30.0-01-win64\sonatype-work\nexus3
默认密码
E:\Program Files (x86)\nexus\nexus-3.30.0-01-win64\sonatype-work\nexus3\admin.password
把密码复制出来,账号admin。
创建阿里云仓库:
Repository-->Repositories-->Create repository-->maven2(proxy)
配置仓库组(默认已有一个maven-public)
Repository-->Repositories-->Create repository-->maven2(group)
注:注意仓库顺序。maven查找依赖时会依次遍历仓库组中的仓库。
创建角色
我的配置
nx-admin被占用,我该为nx-yyh
创建用户
Security-->Users-->Create
创建第三方库
方便自己上传jar包
路径
Repository-->Repositories-->Create repository-->maven2(hosted)
修改仓库组
Repository-->Repositories-->Create repository-->maven2(group)
创建spring-plugin、spring和JBoss
镜像来自于网络,可以参考阿里云镜像
maven配置修改
我的配置
setting.xml
<?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">
<!-- 激活两个配置一个是jdk 一个是私服配置-->
<activeProfiles>
<activeProfile>my-nexus</activeProfile>
<activeProfile>jdk-1.8</activeProfile>
</activeProfiles>
<localRepository>D:\programfile\MavenWM</localRepository>
<servers>
<!--第一个nexus-xu要和下面的mirror中的id一致,代表拉取是也需要进行身份校验-->
<server>
<id>nexus-yyh</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<!--对应项目里面的-->
<id>releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
<mirrors>
<mirror>
<id>nexus-yyh</id>
<name>internal nexus repository</name>
<!--镜像采用配置好的组的地址-->
<url>http://192.168.50.39:8081/repository/my-group/</url>
<mirrorOf>*</mirrorOf>
</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>
<profile>
<id>my-nexus</id>
<!-- 远程仓库列表 -->
<repositories>
<repository>
<id>nexus-yyh</id>
<name>Nexus Central</name>
<!-- 虚拟的URL形式,指向镜像的URL-->
<url>http://192.168.50.39:8081/repository/my-group/</url>
<layout>default</layout>
<!-- 表示可以从这个仓库下载releases版本的构件-->
<releases>
<enabled>true</enabled>
</releases>
<!-- 表示可以从这个仓库下载snapshot版本的构件 -->
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<!-- 插件仓库列表 -->
<pluginRepositories>
<pluginRepository>
<id>nexus-yyh</id>
<name>Nexus Central</name>
<url>http://192.168.50.39:8081/repository/spring-plugin/</url>
<layout>default</layout>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
</settings>
项目配置
重点是distributionManagement配置
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<distributionManagement>
<repository>
<id>releases</id>
<name>Nexus Release Repository</name>
<url>http://192.168.50.39:8081/repository/my-group/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Nexus Snapshot Repository</name>
<url>http://192.168.50.39:8081/repository/my-group/</url>
</snapshotRepository>
</distributionManagement>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-boot.version>2.3.7.RELEASE</spring-boot.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.4.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.3.7.RELEASE</version>
<configuration>
<mainClass>com.example.demo.DemoApplication</mainClass>
</configuration>
<executions>
<execution>
<id>repackage</id>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>