maven工程配置私库「建议收藏」

maven工程配置私库「建议收藏」为什么要配置私库?从中央仓库下载速度缓慢,而且有些jar包是公司私有的包不存在在中央仓库当中,所以我们需要配置私库。首先去修改setting文件,在maven文件夹下的conf文件夹当中<?xmlversion=”1.0″encoding=”UTF-8″?><settingsxmlns=”http://maven.apache.org/SETTINGS/1.0.0″…

大家好,又见面了,我是你们的朋友全栈君。

为什么要配置私库?
从中央仓库下载速度缓慢,而且有些jar包是公司私有的包不存在在中央仓库当中,所以我们需要配置私库。

首先去修改setting文件,在maven文件夹下的conf文件夹当中

<?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>F:/.m2/repository</localRepository>
  
  <pluginGroups>
  </pluginGroups>

  <proxies>
  </proxies>

  <!--设置私库认证信息-->
  <servers>
	  <server>
	    <!--这里的id要与稍后配置的pom中的id一致-->
	    <id>nexus-releases</id> 
	    <username>admin</username>(这里用的是默认的用户名和密码 一般普通的私库都会有)
	    <password>admin123</password>
	  </server>
	  <server>
	    <id>nexus-snapshots</id>
	    <username>admin</username>
	    <password>admin123</password>
	  </server>
  </servers>
  
  <!--设置私库mirror 表示maven所有的请求都由nexus来处理-->
  <mirrors>
	<mirror>
		<id>nexus</id>
		<mirrorOf>*</mirrorOf>
		<name>Nexus Mirror.</name>
		<url>http://localhost:8081/nexus/content/groups/public</url>(在实际应用中如果连接的是别人的私库,localhost要改成对方的ip地址才行,路径也是不一样的)
	</mirror>
  </mirrors>

  <!--设置maven私库信息-->
  <profiles>  
	<profile>
		<id>nexus</id>
		<repositories>
		  <repository>
			<id>nexus</id>
			<name>Nexus</name>
			<url>http://localhost:8081/nexus/content/groups/public/</url>
			(在实际应用中如果连接的是别人的私库,localhost要改成对方的ip地址才行,路径也是不一样的)
			<releases><enabled>true</enabled></releases>
			<snapshots><enabled>true</enabled></snapshots>
		  </repository>
		</repositories>
		<pluginRepositories>
		  <pluginRepository>
			<id>nexus</id>
			<name>Nexus</name>
			<url>http://localhost:8081/nexus/content/groups/public/</url>
			(在实际应用中如果连接的是别人的私库,localhost要改成对方的ip地址才行,路径也是不一样的)
			<releases><enabled>true</enabled></releases>
			<snapshots><enabled>true</enabled></snapshots>
		  </pluginRepository>
		</pluginRepositories>
    </profile>
    <!--覆盖maven中央仓库设置开启releases和snapshots版本的下载-->
	<profile>
		<id>central</id>
		<repositories>
			 <repository>
				<id>central</id>
				<url>http://central</url>
				<releases><enabled>true</enabled></releases>
			    <snapshots><enabled>true</enabled></snapshots>
			</repository>
		</repositories>
		<pluginRepositories>
			<pluginRepository>
				<id>central</id>
				<url>http://central</url>
				<releases><enabled>true</enabled></releases>
			    <snapshots><enabled>true</enabled></snapshots>
			</pluginRepository>
		</pluginRepositories>
    </profile>
  </profiles>

  <!--激活私库信息的配置-->
	<activeProfiles>
	    <activeProfile>nexus</activeProfile>
		<activeProfile>central</activeProfile>
	</activeProfiles>
</settings>

在项目的pom文件中做如下设置

<distributionManagement>
	<repository>
		<id>nexus-releases</id>(注意id要与之前配的setting当中配的id对应)
		<name>Nexus Releases Repository</name>(随意取名)
		<url>http://localhost:8081/nexus/content/repositories/releases/</url>(连接别人的私库需要改成对方的ip地址和路径)
	</repository>
	<snapshotRepository>
		<id>nexus-snapshots</id>
		<name>Nexus Snapshots Repository</name>
		<url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
	</snapshotRepository>
</distributionManagement>

转自:https://www.xuebuyuan.com/1868949.html

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/161250.html原文链接:https://javaforall.net

赞 (0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • spdlog用法

    spdlog用法转自:https://blog.csdn.net/haojie_superstar/article/details/89383433?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-19.control&dist_request_id=1328730.643.16167433128441371&depth_1-utm_source=distribute.pc_relevant.none-task-bl

    2022年6月23日
  • 邓白氏编码申请条件_苹果邓白氏码申请教程

    邓白氏编码申请条件_苹果邓白氏码申请教程一、填写申请表单申请苹果开发者账号途中,我们会用到邓白氏编码,申请邓白氏编码的入口自然也是在申请苹果开发者账号途中进入。1.登录AppID登录入口:https://developer.apple.com/account/.公司开发者账号一般都是由老板来管理的,所以使用老板的个人AppID登录就好了,没有就让老板申请一个。登录进来后进行以下操作:选择Company/Origani

    2022年11月1日
  • PHP数组详解

    作为一名C++程序员,在转做PHP开发的过程中,对PHP数组产生了一些混淆,与C++数组有相似的地方,也有一些不同,下面就全面地分析一下PHP的数组及其与C++中相应数据类型的区别和联系。数组的分类

    2021年12月27日
  • python中的split()函数的用法「建议收藏」

    python中的split()函数的用法「建议收藏」函数:split()Python中有split()和os.path.split()两个函数,具体作用如下:split():拆分字符串。通过指定分隔符对字符串进行切片,并返回分割后的字符串列表(lis

    2022年7月5日
  • java datagramsocket,Java DatagramSocket和DatagramPacket[通俗易懂]

    java datagramsocket,Java DatagramSocket和DatagramPacket[通俗易懂]JavaDatagramSocket和DatagramPacket1JavaDatagramSocket和DatagramPacketJavaDatagramSocket和DatagramPacket类用于无连接Socket编程。2JavaDatagramSocket类JavaDatagramSocket类表示用于发送和接收数据报包的无连接Socket。DatagramSocket基…

    2022年6月12日
  • 飞鸽传书:谈谈RenderControl手动调用「建议收藏」

    飞鸽传书:谈谈RenderControl手动调用「建议收藏」有些网页需要在后台动态创建服务器控件,并且将控件的html代码写入到指定的HtmlTextWriter.如果仅是调用RenderControl方法能够将服务器控件的html内容输出,但它并不会执行OnPreRender,但是通常服务器控件都重写了OnPreRender方法,实现了许多重要的功能.我们不能将其舍弃啊.

    2022年7月21日

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号