首页 > 其他 > 详细

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

时间:2014-06-22 19:27:34      阅读:453      评论:0      收藏:0      [点我收藏+]

下载安装


下载地址

修改默认端口:


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

bubuko.com,布布扣


登录


http://localhost:9080/nexus


用户名、密码:admin/admin123

bubuko.com,布布扣


仓库说明


bubuko.com,布布扣


索引:


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

bubuko.com,布布扣


手动更新索引


下载索引包

停止服务

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

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

bubuko.com,布布扣

查看索引

bubuko.com,布布扣


搜索服务

bubuko.com,布布扣



设置镜像

  <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>

bubuko.com,布布扣



项目部署及远程仓库认证


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


登录私服查看结果

bubuko.com,布布扣


快照版本:


bubuko.com,布布扣


项目构建之maven篇:5.仓库及nexus创建私服-2,布布扣,bubuko.com

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

原文:http://blog.csdn.net/wobendiankun/article/details/31850003

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!