Centos7.0下Nexus私服搭建

1.下载nexus

wget https://sonatype-download.global.ssl.fastly.net/nexus/oss/nexus-2.11.2-03-bundle.tar.gz

2.解压,会出现两个目录,nexus-2.11.2-03是服务  sonatype-work是私有库目录

mkdir nexus
tar -zxvf nexus-2.11.2-03-bundle.tar.gz -C ./nexus

3.修改配置,在nexus-2.11.2-03/bin目录下修改nexus文件

NEXUS_HOME=“安装目录”
RUN_AS_USER=xxx

4.修改端口,nexus-2.11.2-03/conf修改nexus.properties文件

application-port=XXX

5.启动

./bin/nexus start
Starting Nexus OSS...
Started Nexus OSS.

6.修改密码

admin:该用户拥有Nexus的全部权限,默认密码为admin123。
deployment:该用户能够访问Nexus,浏览仓库内容、搜索、上传部署构件,但是不能对Nexus进行任何配置,默认密码为deployment123。
anonymous:该用户对应了所有未登录的匿名用户,它们可以浏览仓库并进行搜索。

7.上传Jar包

参考:上传jar包到nexus私服

登录之后可以看到如下仓库

 

<1>如果上传的是第三方的jar包

在图中填入相应的jar包的信息就可以了

同时在maven的setting.xml文件中配置

  <servers>
	<server>    
		<id>nexus-releases</id>    
		<username>admin</username>    
		<password>xxxx</password>    
	</server>    
	<server>    
		<id>nexus-snapshots</id>    
		<username>admin</username>    
		<password>xxxx</password>    
	</server> 
  </servers>

 以及

<mirror>
    <id>mynexus</id>
    <mirrorOf>central</mirrorOf>
    <name>My Nexus</name>
    <url>http://XXX/nexus/content/repositories/thirdparty/</url>
</mirror>

 <2>上传snapshot包

在工程的pom文件中配置

    <distributionManagement>
        <repository>
            <id>nexus-releases</id>
            <name>Nexus Release Repository</name>
            <url>http://XXX/nexus/content/repositories/releases/</url>
        </repository>
        <snapshotRepository>
            <id>nexus-snapshots</id>
            <name>Nexus Snapshot Repository</name>
            <url>http://XXX/nexus/content/repositories/snapshots/</url>
        </snapshotRepository>
    </distributionManagement>

 

 同时在maven的setting.xml文件中配置

    </profiles>
		<profile>    
			<id>nexus</id>    
			<repositories>    
				<repository>    
					<id>nexus-releases</id>    
					<url>http://nexus-releases</url>    
					<releases><enabled>true</enabled></releases>    
					<snapshots><enabled>true</enabled></snapshots>    
				</repository>    
				<repository>    
					<id>nexus-snapshots</id>    
					<url>http://nexus-snapshots</url>    
					<releases><enabled>true</enabled></releases>    
					<snapshots><enabled>true</enabled></snapshots>    
				</repository>    
			</repositories>    
			<pluginRepositories>    
				<pluginRepository>    
					<id>nexus-releases</id>    
					<url>http://nexus-releases</url>    
					<releases><enabled>true</enabled></releases>    
					<snapshots><enabled>true</enabled></snapshots>    
				</pluginRepository>    
				<pluginRepository>    
					<id>nexus-snapshots</id>    
					<url>http://nexus-snapshots</url>    
					<releases><enabled>true</enabled></releases>    
					<snapshots><enabled>true</enabled></snapshots>    
				</pluginRepository>    
			</pluginRepositories>    
		</profile>    
	</profiles>

	<activeProfiles>    
		<activeProfile>nexus</activeProfile>    
	</activeProfiles> 

 然后在项目下运行,就会生成snapshot包

mvn deploy

 

posted @ 2018-05-13 00:29  tonglin0325  阅读(483)  评论(0编辑  收藏  举报