一、下载
Nexus的下载地址:https://www.sonatype.com/download-oss-sonatype
二、安装
创建文件夹Neuxs,将下载的文件上传
tar -zxvf nexus-2.14.5-02-bundle.tar.gz
查看目录文件:
nexus-2.11.2-03 sonatype-work
(一个 nexus 服务,一个私有库目录)
三、修改配置文件
3.1修改nexus.properties 文件
进入Neuxs的conf目录编辑配置nexus.properties 文件,配置端口和 work 目录信息,我这里是保持的默认
vi nexus-2.14.5-02/conf/nexus.properties
3.2编辑 nexus 脚本, 配置 RUN_AS_USER 参数(不改启动报错)
# vi / nexus-2.14.5-02/bin/nexus
#RUN_AS_USER=
改为:
RUN_AS_USER=root
3.3 打开防火墙端口8081
# vi /etc/sysconfig/iptables
添加:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8081 -j ACCEPT
保存后重启防火墙
# service iptables restart
四、启动登录
启动nexus
[root@localhost bin]# nexus start
登录
192.168.251.130:8081/nexus
用户名:admin
密码:admin123
对Nexus页面中元素的介绍和需要配置的参数请参考
Window搭建maven私服
五、私服的使用
maven私服的使用请参考
Window搭建maven私服
六.本地maven的Setting.xml配置
配置Nexus的用户名和密码,目的是为了我们把本地的项目发布到私服中。
<server>
<id>releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>Snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
配置私服的镜像
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://192.168.251.130:8081/nexus/content/groups/public/</url>
</mirror>
下边的配置是让加载jar从私服中加载和默认的jdk
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>central</id>
<url>http://repo1.maven.org/maven2/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://repo1.maven.org/maven2/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
<profile>
<id>jdk17</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.7</jdk>
</activation>
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion>
</properties>
</profile>
激活profile
<!-- 激活profile,注意id对应-->
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>