Maven 私服搭建

为什么搭建Maven  私服

因为在 java开发中,经常用到第三方的 jar 包依赖,而这些依赖很乱,很杂,构建过程中经常产生意想不到的冲突,比如  jar 包冲突,版本不对等。如果能够用软件的方式,一条命令,快速的搭建 ssh(struct,spring,hibernate),ssi(struct, spring, ibatis) 开发环境,那会节省我们很多的时间去专注研发上 。

私服其实就是一种maven服务器,仅仅服务于某个公司,政府。把它架设在局域网的内部有很多好处,下载依赖变得快了,构建也快了,提高了工作效率。不需要担心找不到  jar 的问题,因为你可以配置maven 仓库。如果你需要下载一个jar包,突然发现私服没有,这时候私服会去外部的仓库下载,下载完后再发给你。以后就不需要再去网络上下载这个 jar 包了。一句话就是“一次投资,终生受益”。

另外,你还可以把你写的  jar 包发布到 maven 库里,供大家使用,仅仅只需要一条命令。

网络拓扑如下(截书里的)

下载并运行

需要准备一台服务器,linux  或者windows 都可以

下载地址:http://www.sonatype.org/nexus/downloads/

解压缩

启动  maven 服务器

进入解压目录

cd nexus-2.11.1-01-bundle/nexus-2.11.1-01/bin

然后执行

./nexus console

看到启动信息 jetty start 即启动成功,默认监听端口为:8081

http:// maven 服务器的ip:8081/nexus/#welcome

打开上面的链接,访问成功即可完成运行。

是不是很简单?

右上角的login in 默认密码是admin  admin123  登陆后可修改私服的配置信息

配置

需要配置本地 Maven Home目录的 conf 目录里的 settings.xml 文件

<?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
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  -->
  
  <localRepository>E:/lib</localRepository>
  <pluginGroups>
  </pluginGroups>
  <proxies>
  </proxies>
  <servers>
  	 <server>  
            <id>releases</id>  
            <username>admin</username>  
            <password>admin123</password>  
        </server>  
        <server>  
            <id>snapshots</id>  
            <username>admin</username>  
            <password>admin123</password>  
        </server>  
        <server>  
            <id>deploymentRepo</id>  
            <username>admin</username>  
            <password>admin123</password>  
        </server>  
 
  </servers>

  <mirrors>

  </mirrors>
  
  <profiles>
	<profile>
		<id>nexus</id>
			<repositories>
				<repository>  
		        <id>releases</id>  
		        <name>mapbar thirdparty central mirror.</name>  
		        <url>http://192.168.200.5:8081/nexus/content/repositories/springio/</url>  
	   		 </repository>
			<repository>
				<id>nexus</id>
				<name>Nexus</name>
				<url>http://192.168.200.5:8081/nexus/content/groups/public/</url>
				<releases>
					<enabled>true</enabled>
				</releases>
				<snapshots>
					<enabled>true</enabled>
				</snapshots>
			</repository>
		</repositories>
		<pluginRepositories>
			<pluginRepository>
				<id>nexus</id>
				<name>Nexus</name>
				<url>http://192.168.200.5:8081/nexus/content/groups/public/</url>
				<releases>
					<enabled>true</enabled>
				</releases>
				<snapshots>
					<enabled>true</enabled>
				</snapshots>
			</pluginRepository>
		</pluginRepositories>
	</profile>

  </profiles>

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

 
</settings>

里面的ip 填写你maven 服务器的ip 即可,就可以执行maven install , 然后你就会发现e:\lib 里面已经有了jar包,当然maven 服务器也有了,下次编译就不会去网络上找jar 包了。

时间: 2024-07-30 19:30:28

Maven 私服搭建的相关文章

Maven私服搭建

1. 为什么使用Nexus 如果没有私服,我们所需的所有构件都需要通过maven的中央仓库和第三方的Maven仓库下载到本地,而一个团队中的所有人都重复的从maven仓库下载构件无疑加大了仓库的负载和浪费了外网带宽,如果网速慢的话,还会影响项目的进程.很多情况下项目的开发都是在内网进行的,连接不到maven仓库怎么办呢?开发的公共构件怎么让其它项目使用?这个时候我们不得不为自己的团队搭建属于自己的maven私服,这样既节省了网络带宽也会加速项目搭建的进程,当然前提条件就是你的私服中拥有项目所需的

Nexus Maven 私服搭建

1.下载Nexus安装文件:http://www.sonatype.org/nexus/go ,目前是nexus-2.13.0-01-bundle.tar.zip这个最新版本: 2.解压到任意目录,我这里解压到E盘,进入F:\nexus-2.13.0-01\bin\jsw\windows-x86-64,点击install-nexus.bat安装成为windows服务,这里选择自己计算机对应的文件: 3.访问http://localhost:8081/nexus/,这就是私服:默认用户名admin

linux环境下jdk 安装以及maven私服搭建

1:准备资源 linux服务器,jdk和nexus  安装包 2:网络通畅,保持windows端和linux服务器端网络通畅. 3: 安装jdk和配置环境变量 进入到jdk安装文件的目录夹 usr/java 1: 进入到安装文件的目录夹  cd ~命令到根目录下  在cd usr/java 2:授权 chmod 755 jdk-7u55-linux-x64.tar.gz 3: tar -zxvf jdk-7u55-linux-x64.tar.gz mv 解压的文件夹名  jdk1.7 修改 /e

windows 环境下Maven私服搭建

使用Nexus.3.11在Windows环境上搭建1.下载nexus.3.11.zip包https://www.sonatype.com/download-oss-sonatype 下载下来之后,进行解压缩 默认情况下,无需修改,但我们须确认一些信息 1=> 端口号修改位置,若后面启动时,端口号占用的情况下,须修改此处2=> nexus启动时的根路径,默认为'\' 二.运行nexus.exe在该目录下cmd打开远程客户端,进入nexus-3.0.1-01\bin下.这里可以在环境变量里把nex

maven私服搭建nexus介绍(二)

1.各个仓库介绍 Hosted:宿主仓库 主要放本公司开发的SNAPSHOTS测试版本,RELEASES正式发行版.合作公司第三方的jar包. Proxy:代理仓库 代理中央仓库:代理Apache下测试版本jar包 Group:组仓库 存放各种仓库(宿主仓库,代理仓库) Virtual:虚拟仓库(废弃) 代理maven1版本的jar包 2.组仓库可进行配置,存放那个仓库(配置后 通过组仓库即可访问配置过的仓库) 3.maven中私服的配置 jar包上传配置 setting.xml中的配置 <se

Maven私服搭建及使用-Windows版

了解有限,目前只针对基础功能介绍,持续更新 一.下载对应的版本(本例版本:nexus-3.7.1-02) https://www.sonatype.com/download-oss-sonatype 二.启动服务,进入对应安装目录,按住shift右键,打开cmd命令行,执行nexus.exe /run 我的Nexus目录:NEXUS_HOME\nexus-3.7.1-02-win64\nexus-3.7.1-02\bin 最后启动成功提示如下,即可访问http://192.168.1.168:8

centos7 nexus maven私服搭建

[[email protected] vhost]# uname -r3.10.0-229.4.2.el7.x86_64 1 安装maven# yum install maven2 下载nexusNexus下载地址:http://www.sonatype.org/nexus/archived/#step2top # wget http://download.sonatype.com/nexus/oss/nexus-2.11.3-01-bundle.tar.gz# tar -zxvf nexus-

maven私服搭建和启动遇到的问题

1.私服下载地址:http://www.sonatype.org/nexus/ 2.在win10中安装nexus时提示:wrapper | OpenSCManager failed - 拒绝访问. (0x5) 主要是没有权限.需要以管理员的身份运行 2.wrapper | The nexus-webapp service is not installed - The specified service does not exist 第一个问题解决之后,又出现了这个问题. 解决方式是到D:\wor

Maven私服搭建(Nexus Repository Manager 3)

下载和安装 下载地址:https://help.sonatype.com/repomanager3/download 注意:Nexus Repository Manager 3是一个Java服务器应用程序,安装需要 jdk1.8以上的版本. 下载解压后,用命令行到解压目录的bin目录下运行 nexus.exe /run(Linux运行./nexus run),启动完成后会显示"Started Sonatype Nexus": ------------------------------