分布式架构学习之持续集成:010--Maven私有库和本地库的安装与配置(Sonatype Nexus + Maven)
2017-05-10 16:18
591 查看
首先安装nexus
环境:CentOS 6.6 Final、JDK7、Sonatype Nexus、Maven
IP:192.168.4.221
root 用户操作
前提:已安装 JDK7 并配置好了环境变量
1、下载最新版 Nexus(本教程使用的是:nexus-2.11.2-03-bundle.tar.gz),下载地址: http://www.sonatype.org/nexus/go/
# wget https://sonatype-download.global.ssl.fastly.net/nexus/oss/nexus-2.11.2-03-bundle.tar.gz
2、解压
# mkdir nexus
# tar -zxvf nexus-2.11.2-03-bundle.tar.gz -C nexus
# cd nexus
# ls
nexus-2.11.2-03 sonatype-work (一个 nexus 服务,一个私有库目录)
3、编辑 Nexus 的 nexus.properties 文件,配置端口和 work 目录信息(保留默认)
# cd nexus-2.11.2-03
# 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
4、编辑 nexus 脚本, 配置 RUN_AS_USER 参数
# vi /root/nexus/nexus-2.11.2-03/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
# /root/nexus/nexus-2.11.2-03/bin/nexus start
****************************************
WARNING - NOT RECOMMENDED TO RUN AS ROOT
****************************************
Starting Nexus OSS...
Started Nexus OSS.
7、浏览器中打开:http://192.168.4.221:8081/nexus/
8、登录,默认用户名 admin,默认密码 admin123:
到此,Nexus 已安装完成,接下来是Nexus 的配置
Nexus 配置(登录后)
1、菜单 Administration/Server 配置邮箱服务地址(如果忘记密码,可以通过该邮箱找回密码)
给用户配置邮箱地址,方便忘记密码时找回:
用户修改密码
2、仓库类型
group 仓库组:Nexus 通过仓库组的概念统一管理多个仓库,这样我们在项目中直接请
maven的配置文件
<?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>E:/apache-maven-3.1.0/.m2/repository</localRepository> <interactiveMode>true</interactiveMode> <offline>false</offline> <pluginGroups> <pluginGroup>org.mortbay.jetty</pluginGroup> <pluginGroup>org.jenkins-ci.tools</pluginGroup> </pluginGroups> <!--配置权限,使用默认用户--> <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>edu</id> <activation> <activeByDefault>false</activeByDefault> <jdk>1.6</jdk> </activation> <repositories> <!-- 私有库地址--> <repository> <id>nexus</id> <url>http://192.168.4.221:8081/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.4.221:8081/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </pluginRepository> </pluginRepositories> </profile> </profiles> <!--激活profile--> <activeProfiles> <activeProfile>edu</activeProfile> </activeProfiles> </settings>
需要上传的地方pom中配置,然后使用clean install deploy 就可以安装到本地和发布,如果某个项目的版本XX.XX.XX-Snapshots就会发布到snapshot中,如果-Releases就会发布到release中。nexus还可以上传第三方jar包。
<distributionManagement>
<repository>
<id>nexus-releases</id>
<name>Nexus Release Repository</name>
<url>http://192.168.100.66:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>nexus-snapshots</id>
<name>Nexus Snapshot Repository</name>
<url>http://192.168.100.66:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
相关文章推荐
- 持续集成篇_04_maven私有库和本地库的安装与配置(sonatype nexus + maven)
- 持续集成--Maven私有库和本地库的安装与配置 Sonatype Nexus + Maven
- Maven私有库和本地库的安装与配置 Sonatype Nexus + Maven
- Maven 私有库和本地库的安装与配置 Sonatype Nexus + Maven
- Maven私有库和本地库的安装与配置 Sonatype Nexus
- 6、Maven私有库和本地库的安装与配置(Sonatype Nexus +Manven)
- Maven 私有库和本地的安装与配置 Sonatype Nexus + Maven
- linux学习:持续集成篇--Maven私有库和本地库的安装与配置-03 推荐
- Maven 私有库和本地库的安装与配置 Sonatype Nexus + Maven
- Maven之——Maven 私有库和本地库的安装与配置(Sonatype Nexus + Maven)
- Maven 私有库和本地库的安装与配置 Sonatype Nexus+Maven
- Maven私有库和本地库的安装与配置 Sonatype Nexus + Maven
- 分布式架构学习之持续集成:011--SonarQube代码质量管理平台的安装、配置和使用
- 分布式架构学习之持续集成:012--Hudson(Jekins)持续集成服务器的安装、配置和使用
- Maven私有库和本地库的安装与配置 Sonatype Nexus + Maven
- Maven私有库和本地库的安装与配置 Sonatype Nexus + Maven
- Maven私有库和本地库的安装与配置 Sonatype Nexus + Maven
- 分布式架构学习之持续集成:009--SVN版本管理系统的安装和使用(CentOS+Subversion+Apache+Jsvnadmin)
- 配置Sonatype Nexus Maven私有仓库(1)
- 持续继承(二)CentOS7下Maven私有库与本地库的安装与配置