6、Maven私有库和本地库的安装与配置(Sonatype Nexus +Manven)

Maven私有库和本地库的安装与配置(Sonatype Nexus +Manven)

环境:JDK1.8、 CenterOS 6.5 、Sonatype Nexus 、Maven
IP 192.168.159.138
root用户操作

1、下载最新版 Nexus 下载地址:http://www.sonatype.org/nexus/go/

2、解压
# mkdir nexus
# tart -zxvf nexus-2.14.5-02-bundle.tar.gz -C nexus
# cd nexus
# ls
nexus-2.14.5-02 sonatype-work (一个nexus服务,一个私有库目录)

3、编辑Nexus 的nexus.properties 文件,配置端口和work目录信息(保留默认)
# cd nexus-2.14.5-02
# ls
bin conf lib LICENSE.txt logs nexus NOTICE.txt tmp
查看目录结构,jetty运行

# cd conf
# vi nexus.properties
# Jetty section
application-port=8081
application-host=0.0.0.0
nexus-webapp=${bundleBasedir}/nexus
nexus-webapp-context-path=/nexus
# Nexus section
nexus-work=${bundleBasedir}/../sonatype-work/nexus
runtime=${bundleBasedir}/nexus/WEB-INF

# orientdb buffer size in megabytes
storage.diskCache.bufferSize=4096


4、编辑nexus脚本,配置RUN_AS_USER参数
# vi /nexus/nexus-2.14.5-02/bin/nexus
#RUN_AS_USER=
改为
RUN_AS_USER=root

5、防火墙打开8081端口
# vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8081-j ACCEPT
重启防火墙
service iptables restart

6、启动 nexus
# /nexus/nexus-2.14.5-02/bin/nexus start
6、Maven私有库和本地库的安装与配置(Sonatype Nexus +Manven)

7、浏览器打开:http://192.168.159.138:8081/nexus/
6、Maven私有库和本地库的安装与配置(Sonatype Nexus +Manven)


8、登录,默认用户名:admin,默认密码:admin123

至此,Nexus已安装完成,接下来是Nexus的配置

Nexus配置(登录后)
1、打开Administration/Server 配置邮箱地址(如果忘记密码,可以通过邮箱找回密码)
2、通过Security/User修改用户的绑定邮箱
3、Repositories 仓库属性介绍
6、Maven私有库和本地库的安装与配置(Sonatype Nexus +Manven)
6、Maven私有库和本地库的安装与配置(Sonatype Nexus +Manven)
6、Maven私有库和本地库的安装与配置(Sonatype Nexus +Manven)



4、设置 proxy 代理仓库,(Apache Snapshots/Central/Codehaus Snapshots) 准许远程下载 如:
6、Maven私有库和本地库的安装与配置(Sonatype Nexus +Manven)

5、Maven 本地库的安装与配置
环境变量、setting.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">
<interactiveMode>true</interactiveMode>
<pluginGroups>
<pluginGroup>com.mortbay.jetty</pluginGroup>
<pluginGroup>com.jenkins-ci.tools</pluginGroup>
</pluginGroups>
<proxies>
</proxies>
<!-- 配置权限,使用默认用户-->
<servers>
<server>
<id>nexus-releases</id>
<username>deployment</username>
<password>deployment123</password>
</server>
<server>
<id>nexus-snapshots</id>
<username>deployment</username>
<password>deployment123</password>
</server>
</servers>
<mirrors>
</mirrors>
<profiles>
<profile>
<id>com-njztc</id>
<activation>
<activeByDefault>false</activeByDefault>
<jdk>1.7</jdk>
</activation>
<repositories>
<!--私有库地址-->
<repository>
<id>nexus</id>
<url>http://192.168.159.138/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<!--插件库地址-->
<pluginRepository>
<id>nexus</id>
<url>http://192.168.159.138/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>com-njztc</activeProfile>
</activeProfiles>
<localRepository>C:\local-private-maven\repository</localRepository>
</settings>

6、IDE工具中的Maven配置
6、Maven私有库和本地库的安装与配置(Sonatype Nexus +Manven)
7、项目的构建与发布演示
修改common-parent 中的pom.xml中的私有库地址
6、Maven私有库和本地库的安装与配置(Sonatype Nexus +Manven)