1 Star 1 Fork 0

hyx-work / 二十年嵌入式老兵做Java-wnexus

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

不要错过的任何机会 二十年嵌入式老兵做Java

0 解压到任意盘根目录

  1. 将 nexus-private-service.zip 解压到任意盘的根目录

  2. 解压SwitchHosts!_windows_portable_3.5.0(5486).zip到任意目录,以管理员权限运行exe文件,增加 127.0.0.1 private.nexus.net

1 修改默认端口:

cd nexus-3.19.1-01\bin\etc
打开 nexus-default.properties并编辑

application-port=3001
application-host=0.0.0.0

2 nexus安装与运行

# 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服务

3 浏览器访问

浏览器输入http://127.0.0.1:3001/,点击Sign in登录,nexus 默认的用户名是admin,密码为admin123
如果浏览器访问失败,在nexus-3.19.1-01\bin路径下尝试执行如下命令行操作
# 1重启
nexus restart
# 2强制重新刷新仓库
nexus force-reload

4 maven私服jar包默认存放目录

sonatype-work\nexus3\blobs\default\content

5 项目依赖启用私服

pom文件增加

<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>

6 项目发布到私服仓库

mvn配置文件修改

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

mvn deploy 根据pom的<version></version>是否带**-SNAPSHOT**发布项目到私服的maven-snapshots还是maven-releases

mvn deploy -P release

mvn deploy -P release发布到 maven-releases,POM改动如下

  • <version></version>为变量<version>${project.version}</version>
  • 定义project.version为1.0.0--SNAPSHOT,<project.version>1.0.0-SNAPSHOT</project.version>
  • 增加profiles定义profile id=release的配置,并在下面定义<project.version>1.0.0</project.version>,这样此命令会用release的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>

POM Deploy示例

<?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>

7 制作私服库

通过本地空目录建立

  1. 进入项目根目录,建立settings.xml
<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>

打开cmd程序,下载项目依赖包

下载依赖jar

mvn package -Dmaven.tast.skip=true  -s settings.xml

下载jar和source

mvn package -Dmaven.tast.skip=true  -s settings.xml dependency:sources

下载jar和source和javadoc

mvn package -Dmaven.tast.skip=true -s settings.xml dependency:sources dependency:resolve -Dclassifier=javadoc

通过上述命令之一完成本地仓库和私服仓库的建立。

MIT License Copyright (c) 2021 hyx-work Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

windows nexus3 maven 私服搭建包 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/hyx-work/wnexus.git
git@gitee.com:hyx-work/wnexus.git
hyx-work
wnexus
二十年嵌入式老兵做Java-wnexus
master

搜索帮助