持续继承(二)CentOS7下Maven私有库与本地库的安装与配置

前提:安装了JDK7以上,并且配置了环境变量;

到官网下载:https://www.sonatype.com/download-oss-sonatype

1.下载完成后先解压,解压时创建一个nexus文件夹,将内容解压到这个文件夹。

## 创建文件夹
mkdir /opt/nexus

## 解压文件
tar -zxvf nexus-3.2.0-01-unix.tar.gz -C /opt/nexus

目录中会有两个文件夹,分别是nexus-3.2.0-01和sonatype-work,前者是nexus服务,后者是私有库文件夹。

2.配置nexus

## 进入nexus的配置文件目录
cd /opt/nexus/nexus-3.2.0-01/etc

## 拷贝一份配置文件,不要直接修改default文件
## nexus管理程序运行在jetty上,默认端口为8081
## 可以编辑nexus.properties修改
cp nexus-default.properties nexus.properties

## 配置运行时用户
cd /opt/nexus/nexus-3.2.0-01/bin

## 编辑nexus.rc文件
vi nexus.rc

nexus.rc内容为:

run_as_user=root

3.配置防火墙,打开8081端口

firewall-cmd --zone=public --add-port=8081/tcp --permanent
firewall-cmd --reload

4.启动nexus

## 启动nexus
/opt/nexus/nexus-3.2.0-01/bin/nexus start

浏览器地址栏中输入http://192.168.0.81:8081/

初始帐号与密码:admin,admin123

5.配置本地maven的配置文件

找到配置文件:D:\Soft\apache-maven-3.3.9\conf

修改配置文件

<?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>D:/Soft/apache-maven-3.3.9/.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>ems</id>
			    <activation>
                    <activeByDefault>false</activeByDefault>
                    <jdk>1.8</jdk>
                </activation>
			    <repositories>
					<!-- 私有库地址-->
				    <repository>
						<id>nexus</id>
						<url>http://192.168.0.81: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.0.81:8081/nexus/content/groups/public/</url>
						<releases>
							<enabled>true</enabled>
						</releases>
						<snapshots>
							<enabled>true</enabled>
					   </snapshots>
					</pluginRepository>
				</pluginRepositories>
			</profile>
	</profiles>
	
	<!--激活配置-->
	<activeProfiles>
		<activeProfile>ems</activeProfile>
	</activeProfiles>
	
</settings>

6.设置eclipse的maven插件,选择修改后的maven配置文件

在工程的pom.xml中加入:

<distributionManagement>
		<repository>
			<id>nexus-releases</id>
			<name>Nexus Release Repository</name>
			<url>http://192.168.0.81:8081/repository/maven-releases/</url>
		</repository>
		<snapshotRepository>
			<id>nexus-snapshots</id>
			<name>Nexus Snapshot Repository</name>
			<url>http://192.168.0.81:8081/repository/maven-snapshots/</url>
		</snapshotRepository>
	</distributionManagement>

7.发布工程到私有库

转载于:https://my.oschina.net/u/2450666/blog/823071

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值