CentOS7 下安装 nexus
java环境
检查java环境
java -version
注意: java的版本必须为1.8
查看yum源中是否有相关套件
yum -y list java*
安装java8
yum -y install java-1.8.0-openjdk-devel.x86_64
安装nexus
下载地址
https://help.sonatype.com/repomanager3/product-information/download
下载unix.tar.gz后缀的文件 创建存放目录
mkdir /usr/local/nexux
解压
tar -xzvf nexus-3.38.0-01-unix.tar.gz -C /usr/local/nexux
按需修改端口,默认为8081
vim /usr/local/nexux/nexus-3.38.0-01/etc/nexus-default.properties
修改jdk安装目录
vim /usr/local/nexux/nexus-3.38.0-01/bin/nexus
打开第14行注释并修改
INSTALL4J_JAVA_HOME_OVERRIDE= /usr/bin/java
修改运行用户为root
vim /usr/local/nexux/nexus-3.38.0-01/bin/nexus.rc
打开注释并修改
run_as_user=“root”
设置开机自启动
ln -s /usr/local/nexux/nexus-3.38.0-01/bin/nexus /etc/init.d/nexus3
chkconfig --add nexus3
chkconfig nexus3 on
关闭防火墙
systemctl start firewalld
firewall-cmd --zone=public --add-port=8081/tcp --permanent
systemctl reload firewalld
firewall-cmd --query-port=8081/tcp
后台启动
/usr/local/nexux/nexus-3.38.0-01/bin/nexus run &
默认账号:admin 默认密码
cat /usr/local/nexux/sonatype-work/nexus3/admin.password
nexus 使用
查看java包
删除Java包,:8081/#browse/browse:maven-snapshots:com
Maven 配置
上传到nexus
添置maven pom配置
<distributionManagement>
<repository>
<id>Nexus</id>
<name>Releases</name>
<url>http://ip:8081/repository/maven-releases</url>
</repository>
<snapshotRepository>
<id>Nexus</id>
<name>Snapshot</name>
<url>http://ip:8081/repository/maven-snapshots</url>
</snapshotRepository>
</distributionManagement>
修改Maven settings配置 注意:id一定要对上
<servers>
<server>
<id>Nexus</id>
<username>admin</username>
<password>xxx</password>
</server>
</servers>
推送到远程仓库
mvn clean deploy
从nexus下载
配置镜像源 注意:mirror、profile、activeProfile的标识必须一致
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://ip:8081/nexus/content/groups/public</url>
</mirror>
添加仓库配置
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>https://repo1.maven.org/maven2/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
生效配置
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
|