项目构建之maven篇:5.仓库及nexus创建私服-2

下载安装


下载地址

修改默认端口:


home\conf\nexus.properties


# Sonatype Nexus
# ==============
# This is the most basic configuration of Nexus.

# Jetty section
application-port=9080
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



安装与启动


home\bin\nexus.bat



登录


http://localhost:9080/nexus


用户名、密码:admin/admin123



仓库说明




索引:


有些远程仓库拥有索引,下载其索引后,即使没有缓存远程仓库的jar包,我们也可以在本地搜索jar包的信息



手动更新索引


下载索引包

停止服务

删除 nexus-2.0.3-bundle\sonatype-work\nexus\indexer\central-ctx 下的索引

将下载索引包的所有内容复制到 nexus-2.0.3-bundle\sonatype-work\nexus\indexer\central-ctx ,重启服务且重新登陆


查看索引



搜索服务




设置镜像

  <mirrors>
	  <mirror>
      <id>mirrorId</id>
      <mirrorOf>*</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://localhost:9080/nexus/content/groups/public/</url>
    </mirror>
  </mirrors>


当设置 mirrorOf 为 "*" 时,pom.xml中仓库是可以不用配置了

项目中加入新的依赖,将从私服中下载

		<dependency>
			<groupId>com.demo.test</groupId>
			<artifactId>test-b</artifactId>
			<version>0.0.1-SNAPSHOT</version>
		</dependency>




项目部署及远程仓库认证


pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<groupId>com.demo.test</groupId>
	<artifactId>test-c</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>jar</packaging>

	<name>test-c</name>
	<url>http://maven.apache.org</url>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	</properties>

	<dependencies>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.10</version>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>com.demo.test</groupId>
			<artifactId>test-a</artifactId>
			<version>0.0.1-SNAPSHOT</version>
		</dependency>
		
		<dependency>
			<groupId>com.demo.test</groupId>
			<artifactId>test-d</artifactId>
			<version>0.0.1-SNAPSHOT</version>
			<exclusions>
				<exclusion>
					<groupId>commons-logging</groupId>
					<artifactId>commons-logging</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>com.demo.test</groupId>
			<artifactId>test-b</artifactId>
			<version>0.0.1-SNAPSHOT</version>
		</dependency>
		
		<dependency>
		  <groupId>abbot</groupId>
		  <artifactId>abbot</artifactId>
		  <version>0.12.3</version>
		</dependency>
	</dependencies>
	
	<!-- 部署 -->
	<distributionManagement>
		<!-- 发布版布置仓库 -->
		<repository>
			<id>test-c release</id>
			<name>Test-c Release</name>
			<url>http://localhost:9080/nexus/content/repositories/releases/</url>
		</repository>
		<!-- 快照版布置仓库 -->
		<snapshotRepository>
			<id>test-c snapshot</id>
			<name>Test-c Snapshot</name>
			<url>http://localhost:9080/nexus/content/repositories/snapshots/</url>
		</snapshotRepository>
	</distributionManagement>
	
</project>

部署配置

	<!-- 部署 -->
	<distributionManagement>
		<!-- 发布版布置仓库 -->
		<repository>
			<id>test-c release</id>
			<name>Test-c Release</name>
			<url>http://localhost:9080/nexus/content/repositories/releases/</url>
		</repository>
		<!-- 快照版布置仓库 -->
		<snapshotRepository>
			<id>test-c snapshot</id>
			<name>Test-c Snapshot</name>
			<url>http://localhost:9080/nexus/content/repositories/snapshots/</url>
		</snapshotRepository>
	</distributionManagement>

仓库认证

settings.xml

	<servers>
	 <server>
      <id>test-c release</id>
      <username>deployment</username>
      <password>deployment123</password>
    </server>
	<server>
      <id>test-c snapshot</id>
      <username>deployment</username>
      <password>deployment123</password>
    </server>
  </servers>

运行命令

mvn clean deploy


登录私服查看结果




快照版本:




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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值