代码拉取完成,页面将自动刷新
不要错过的任何机会 二十年嵌入式老兵做Java
将 nexus-private-service.zip 解压到任意盘的根目录
解压SwitchHosts!_windows_portable_3.5.0(5486).zip到任意目录,以管理员权限运行exe文件,增加 127.0.0.1 private.nexus.net
cd nexus-3.19.1-01\bin\etc
打开 nexus-default.properties并编辑
application-port=3001
application-host=0.0.0.0
# 1进入bin目录
cd nexus-3.19.1-01\bin
# 2安装服务
nexus.exe /install //安装nexus服务
net start nexus //启动nexus服务
# 3卸载服务
net stop nexus //关闭nexus服务
nexus.exe /uninstall //卸载nexus服务
浏览器输入http://127.0.0.1:3001/,点击Sign in登录,nexus 默认的用户名是admin,密码为admin123
如果浏览器访问失败,在nexus-3.19.1-01\bin路径下尝试执行如下命令行操作
# 1重启
nexus restart
# 2强制重新刷新仓库
nexus force-reload
sonatype-work\nexus3\blobs\default\content
<repositories>
...
<repository>
<id>nexus-private-service</id>
<name>nexus private service</name>
<url>http://private.nexus.net:3001/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</pluginRepositories>
...
<pluginRepository>
<id>nexus-private-service</id>
<name>nexus private service</name>
<url>http://private.nexus.net:3001/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
maven settings.xml配置文件加入server nexus-private-service
<servers>
<server>
<id>nexus-private-service</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
项目pom文件加入distributionManagement发布私服配置:
repository id必须与mvn的settings.xml server id配置一致
<project>
...
<distributionManagement>
<repository>
<id>nexus-private-service</id>
<url>http://private.nexus.net:3001/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>nexus-private-service</id>
<url>http://private.nexus.net:3001/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
</project>
项目pom文件加入maven-source-plugin发布源码配置:
<project>
...
<build>
<plugins>
<!-- 要将源码放上去,需要加入这个插件 -->
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>2.4</version>
<configuration>
<attach>true</attach>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
...
</project>
项目pom文件加入maven-javadoc-plugin发布文档配置:
<project>
...
<build>
<plugins>
<!-- Javadoc -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<show>private</show>
<nohelp>true</nohelp>
<charset>UTF-8</charset>
<encoding>UTF-8</encoding>
<docencoding>UTF-8</docencoding>
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
...
</project>
mvn deploy
根据pom的<version></version>
是否带**-SNAPSHOT**发布项目到私服的maven-snapshots
还是maven-releases
mvn deploy -P release
发布到 maven-releases
,POM改动如下
<version></version>
为变量<version>${project.version}</version>
<project.version>1.0.0-SNAPSHOT</project.version>
</project>
...
<version>${project.version}</version>
...
<properties>
<project.version>1.0.0-SNAPSHOT</project.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
...
<profiles>
<profile>
<id>release</id>
<properties>
<project.version>1.0.0</project.version>
</properties>
</profile>
</profiles>
</project>
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test.deploy</groupId>
<artifactId>test-dependencies-parent</artifactId>
<version>${project.version}</version>
<packaging>pom</packaging>
<name>test-dependencies-parent</name>
<description>test maven 私服发布</description>
<properties>
<project.version>1.0.0-SNAPSHOT</project.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<profiles>
<profile>
<id>release</id>
<properties>
<project.version>1.0.0</project.version>
</properties>
<build>
<plugins>
<!-- GPG -->
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-gpg-plugin</artifactId>-->
<!-- <version>1.5</version>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <phase>verify</phase>-->
<!-- <goals>-->
<!-- <goal>sign</goal>-->
<!-- </goals>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->
<!-- <plugin>-->
<!-- <groupId>org.sonatype.plugins</groupId>-->
<!-- <artifactId>nexus-staging-maven-plugin</artifactId>-->
<!-- <version>1.6.8</version>-->
<!-- <extensions>true</extensions>-->
<!-- <configuration>-->
<!-- <serverId>sonatype</serverId>-->
<!-- <nexusUrl>https://oss.sonatype.org/</nexusUrl>-->
<!-- <autoReleaseAfterClose>true</autoReleaseAfterClose>-->
<!-- </configuration>-->
<!-- </plugin>-->
</plugins>
</build>
</profile>
</profiles>
<build>
<plugins>
<!-- Source -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Javadoc -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<show>private</show>
<nohelp>true</nohelp>
<charset>UTF-8</charset>
<encoding>UTF-8</encoding>
<docencoding>UTF-8</docencoding>
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<distributionManagement>
<repository>
<id>nexus-private-service</id>
<url>http://private.nexus.net:3001/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>nexus-private-service</id>
<url>http://private.nexus.net:3001/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
</project>
<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-->
<localRepository>./.apache-maven-repo</localRepository>
<!-- servers
| This is a list of authentication profiles, keyed by the server-id used within the system.
| Authentication profiles can be used whenever maven must make a connection to a remote server.
|-->
<servers>
<server>
<id>nexus-private-service</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
</settings>
mvn package -Dmaven.tast.skip=true -s settings.xml
mvn package -Dmaven.tast.skip=true -s settings.xml dependency:sources
mvn package -Dmaven.tast.skip=true -s settings.xml dependency:sources dependency:resolve -Dclassifier=javadoc
通过上述命令之一完成本地仓库和私服仓库的建立。
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。