文章目录
1, 安装使用
下载:https://help.sonatype.com/repomanager3/download/download-archives—repository-manager-3
修改配置文件(端口),测试运行 :https://help.sonatype.com/repomanager3/installation/configuring-the-runtime-environment
使用init.d自动启动服务:https://help.sonatype.com/repomanager3/installation/run-as-a-service
wget -c http://download.sonatype.com/nexus/3/nexus-3.27.0-03-unix.tar.gz
tar -xf nexus-3.27.0-03-unix.tar.gz -C /usr/local/share/
#修改配置
sed -i 's/8081/65088/' /usr/local/share/nexus-3.27.0-03/etc/nexus-default.properties
#开机启动
ln -s /usr/local/share/nexus-3.27.0-03/bin/nexus /etc/init.d/
echo 'run_as_user="test"' >> /usr/local/share/nexus-3.27.0-03/bin/nexus.rc
chown -R test. /usr/local/share/nexus-3.27.0-03
[root@test datax-plug]# /usr/local/share/nexus-3.27.0-03/bin/nexus
Usage: /usr/local/share/nexus-3.27.0-03/bin/nexus {
start|stop|run|run-redirect|status|restart|force-reload}
#查看日志
[root@eadage datax-plug]# tailf /usr/local/share/sonatype-work/nexus3/log/nexus.log
2020-09-25 12:43:13,703+0800 INFO [jetty-main-1] *SYSTEM org.apache.shiro.nexus.NexusWebSessionManager - Global session timeout: 1800000 ms
2020-09-25 12:43:13,704+0800 INFO [jetty-main-1] *SYSTEM org.apache.shiro.nexus.NexusWebSessionManager - Session-cookie prototype: name=NXSESSIONID
2020-09-25 12:43:13,743+0800 INFO [jetty-main-1] *SYSTEM org.sonatype.nexus.extender.NexusBundleTracker - ACTIVATING org.sonatype.nexus.common [3.27.0.03]
2020-09-25 12:43:13,829+0800 INFO [jetty-main-1] *SYSTEM org.hibernate.validator.internal.util.Version - HV000001: Hibernate Validator 6.1.0.Final
2020-09-25 12:43:14,022+0800 INFO [jetty-main-1] *SYSTEM org.sonatype.nexus.extender.NexusBundleTracker - ACTIVATED org.sonatype.nexus.common [3.27.0.03]
2020-09-25 12:43:14,023+0800 INFO [jetty-main-1] *SYSTEM org.sonatype.nexus.extender.NexusBundleTracker - ACTIVATING org.apache.tika.core [1.24.1]
配置仓库:proxy url, allow redeploy
启动后,访问仓库,并添加用户;修改中央仓库Proxy的远程仓库地址
2, maven 项目配置nexus私服
a, 配置项目pom.xml
[root@eadage datax-plug]# tail -n 34 pom.xml
<repositories>
<repository>
<id>releases</id>
<name>Nexus Release Repository</name>
<snapshots>
<enabled>false</enabled>
</snapshots>
<url>http://192.168.56.111:65088/repository/maven-releases/</url>
</repository>
<repository>
<id>snapshot</id>
<name>Apache Snapshot Repository</name>
<url>http://192.168.56.111:65088/repository/maven-snapshots/</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>releases</id>
<name>Nexus Release Repository</name>
<url>http://192.168.56.111:65088/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Nexus Snapshot Repository</name>
<url>http://192.168.56.111:65088/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
</project>
2, 配置本地maven安装目录:conf/settings.xml
[root@eadage datax-plug]# cat /apache-maven-3.6.3/conf/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">
<!-- 本地仓库的位置 -->
<!-- <localRepository>${user.home}/.m2/repository</localRepository> -->
<localRepository>/apache-maven-3.6.3/repository</localRepository>
<!-- Apache Maven 配置 -->
<pluginGroups/>
<proxies/>
<!-- nexus账号密码 -->
<servers>
<server>
<id>releases</id>
<username>wang</username>
<password>123456</password>
</server>
<server>
<id>snapshots</id>
<username>wang</username>
<password>123456</password>
</server>
</servers>
<!-- nexus私服镜像 -->
<mirrors>
<mirror>
<id>nexus maven</id>
<name>nexus-self</name>
<url>http://192.168.56.111:65088/repository/maven-central/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<profiles>
<!-- 全局JDK1.8配置 -->
<profile>
<id>jdk1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<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>
<!-- Nexus私服配置: 第三方jar包下载, 比如oracle的jdbc驱动等 -->
<profile>
<id>local-snapshot</id>
<repositories>
<repository>
<id>snapshot</id>
<name>Apache Snapshot Repository</name>
<url>http://192.168.56.111:65088/repository/maven-snapshots/</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>snapshots</id>
<name>Nexus Snapshot Repository</name>
<url>http://192.168.56.111:65088/repository/maven-snapshots/</url>
</pluginRepository>
</pluginRepositories>
</profile>
<!-- 阿里云配置: 提高国内的jar包下载速度 -->
<profile>
<id>ali</id>
<repositories>
<repository>
<id>ali</id>
<name>aliyun maven</name>
<!-- <url>http://maven.aliyun.com/nexus/content/groups/public/</url> -->
<url>http://192.168.56.111:65088/repository/maven-central/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://192.168.56.111:65088/repository/maven-central/</url>
<!-- <url>http://maven.aliyun.com/nexus/content/groups/public/</url> -->
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<!-- 激活配置 -->
<activeProfiles>
<activeProfile>local-snapshot</activeProfile>
<activeProfile>jdk1.8</activeProfile>
<activeProfile>ali</activeProfile>
</activeProfiles>
</settings>