Nexus私服的安装和使用

Nexus私服的安装和使用

本文是基于CentOS 7.3系统环境,安装和使用Nexus服务器

  • CentOS 7.3
  • nexus-2.12.0-01-bundle.tar.gz

一、Nexus的安装

(1) 官网下载

nexus-2.12.0-01-bundle.tar.gz

(2) 需要依赖jvm环境

安装jdk的步骤,详情

(3) 解压Nexus

tar -xzvf nexus-2.12.0-01-bundle.tar.gz

(4) 配置环境变量

vi ~/.bashrc
# 
export RUN_AS_USER=root
source ~/.bashrc

(5) 开放防火墙端口

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

(6) 开启Nexus服务

cd nexus-2.12.0-01/bin
./nexus start
# 完全开启,需要等待一分钟

(5) 验证nexus是否开启

  • 浏览器打开网址:http://localhost:8081/nexus
  • 用户名:admin
  • 密码:admin123

二、Nexus的使用

通过上述过程,Nexus的服务端已经安装并配置好,下面在配置客户端的信息,并使用Nexus

(1) 配置maven的setting.xml

 

<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:/RepositorylocalRepository>
  
  <pluginGroups>
  pluginGroups>

  <proxies>
  proxies>

  <servers>
	<server>
	 
      <id>releasesid>
	  
      <username>adminusername>
      <password>admin123password>
    server>
	<server>
	
      <id>snapshotsid>
	  
      <username>adminusername>
      <password>admin123password>
    server>
  servers>

  <mirrors>
	 <mirror>
      <id>nexus-releasesid>
      <mirrorOf>*mirrorOf>
      <url>http://192.168.0.129:8081/nexus/content/groups/public/url>
     mirror>
	 <mirror>
      <id>nexus-snapshotsid>
      <mirrorOf>*mirrorOf>
      <url>http://192.168.0.129:8081/nexus/content/repositories/apache-snapshotsurl>
     mirror>
	 <mirror>
		<id>alimavenid>
		<mirrorOf>centralmirrorOf>
		<name>alimavenname>
		<url>http://maven.aliyun.com/nexus/content/groups/publicurl>
    mirror>
  mirrors>

  <profiles>
	<profile>
		<id>jdk-1.8id>
		<activation>
			<activeByDefault>trueactiveByDefault>
			<jdk>1.8jdk>
		activation>
		<properties>
			<maven.compiler.source>1.8maven.compiler.source>
			<maven.compiler.target>1.8maven.compiler.target>
			<maven.compiler.compilerVersion>1.8maven.compiler.compilerVersion>
		properties>
	profile>
	<profile> 
		
		<id>nexus-serverid>
		<repositories>
			<repository> 
				<id>nexusid> 
				<url>http://192.168.0.129:8081/nexus/content/groups/public/url> 
				<releases>
					<enabled>trueenabled>
				releases> 
				<snapshots>
					<enabled>trueenabled>
				snapshots>
			repository>
		repositories>
		<pluginRepositories> 
			<pluginRepository> 
				<id>publicid>
				<name>Public Repositoriesname>
				<url>http://192.168.0.129:8081/nexus/content/groups/public/url>
			pluginRepository>
		pluginRepositories>
	profile>
  profiles>
  
  <activeProfiles>
	<activeProfile>nexus-serveractiveProfile>
activeProfiles>
settings>

(2) 上传第三方jar包

上传至 /usr/local/soft/nexus/sonatype-work/nexus/storage/releases

(3) 重启nexus

cd nexus-2.12.0-01/bin
./nexus restart
# 完全开启,需要等待一分钟

你可能感兴趣的:(maven)