1. 下载安装 nexus-3.14.04
注意:
nexus-3.14.04
要求安装JDK1.8
以上版本
1.1 下载
下载地址:点击下载
1.2 在Linux(ubuntu-16.04.5_64bit)解压安装
# tar xf nexus-3.14.0-04-unix.tar.gz -C /usr/local/software/
# cd /usr/local/software/nexus-3.14.0-04
1.3 适当修改nexus-3.14.04参数
文件分别为nexus.rc
和nexus.vmoptions
,笔者修改如下:
nexus.vmoptions
文件:
-Xms512M
-Xmx512M
-XX:MaxDirectMemorySize=1G
-XX:+UnlockDiagnosticVMOptions
-XX:+UnsyncloadClass
-XX:+LogVMOutput
-XX:LogFile=../sonatype-work/nexus3/log/jvm.log
-XX:-OmitStackTraceInFastThrow
-Djava.net.preferIPv4Stack=true
-Dkaraf.home=.
-Dkaraf.base=.
-Dkaraf.etc=etc/karaf
-Djava.util.logging.config.file=etc/karaf/java.util.logging.properties
-Dkaraf.data=../sonatype-work/nexus3
-Djava.io.tmpdir=../sonatype-work/nexus3/tmp
-Dkaraf.startLocalConsole=false
nexus.rc
文件:
run_as_user="root"
1.4 启动服务
# /usr/local/software/nexus-3.14.0-04/bin/nexus start
1.5 使用
浏览器访问http://192.168.100.167:8081,使用nexus默认用户名密码登陆admin/admin123,
1.5.1 创建管理用户
你可以配置一个管理用户:
创建页面:
1.5.2 创建仓库
登陆账号并创建自己的release
、snapshot
、proxy
仓库和仓库组:
-
创建
release
仓库,选择如下图中的maven2(hosted)
创建:
-
创建
snapshot
仓库,选择如下图中的maven2(hosted)
创建:
-
创建
proxy
仓库,选择如下图中的maven2(proxy),并配置阿里云为远端仓库:http://maven.aliyun.com/nexus/content/groups/public
创建:
-
创建仓库组用户使用者在
maven
的settings.xml
中配置使用
创建:
2. 使用nexus私服
2.1 配置本地Maven settings.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">
<servers>
<server>
<id>releases</id>
<username>jerry</username>
<password>123456</password>
</server>
<server>
<id>snapshots</id>
<username>jerry</username>
<password>123456</password>
</server>
</servers>
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>central</mirrorOf>
<name>*</name>
<url>http://192.168.100.167:8081/repository/java-public/</url>
</mirror>
</mirrors>
</settings>
2.2 配置项目pom.xml
<?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.zjw</groupId>
<artifactId>my-util</artifactId>
<version>2.1-SNAPSHOT</version>
<distributionManagement>
<repository>
<id>releases</id>
<url>http://192.168.100.167:8081/repository/java-release/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://192.168.100.167:8081/repository/java-snapshot/</url>
</snapshotRepository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>io.perfana</groupId>
<artifactId>perfana-gatling-maven-plugin</artifactId>
<version>3.0.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- 打jar包插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<excludes>
<exclude>**/*.properties</exclude>
</excludes>
</configuration>
</plugin>
<!-- 打包源码插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<attach>true</attach>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>