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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Ubuntu18.04安装GCC8.3.0

    Ubuntu18.04安装GCC8.3.0转自:https://blog.csdn.net/bjzhaoxiao/article/details/102525241Ubuntu系统是自带GCC安装指令的aptinstallgcc,当前apt源中gcc版本为5.4.0,版本太低,推荐手动安装gcc8.3.0手动安装gcc8.3.0之前需要先确保安装gcc环境依赖GMP4.2+、MPFR2.3.1+、MPC0.8.0+,否则会报出以下错误configure:error:BuildingGCCrequiresGMP4.

    2022年7月24日
    3
  • textview长按复制_android-TextView的长按复制[通俗易懂]

    textview长按复制_android-TextView的长按复制[通俗易懂]引子android很多app都支持文本的选中,复制。根据观察,主要分为两类:1)自由复制(弹出框里面支持全选)2)仅支持全选复制今天工作中遇到了全选的需求,现总结出来,方便以后查阅.自由复制这种方式很简单,只需要两行代码,(下面的红色)android:layout_height=”wrap_content”android:text=”长按自由复制”android:textColorHighligh…

    2022年9月29日
    0
  • NOIPD2T2 – 宝藏 题解

    NOIPD2T2 – 宝藏 题解

    2022年4月2日
    33
  • C语言 对数组名取地址

    C语言 对数组名取地址

    2021年12月1日
    45
  • html css制作静态网页_简单的静态网页代码

    html css制作静态网页_简单的静态网页代码网页简介:经过pink老师的课程学习之后,制作了一个简单的静态页面,其中的重点内容是对所学css样式的编写格式,顺序等进行规范练习,对页面结构的规划安排,对html,css基本内容的熟练,对浮动,定位,盒子模型嵌套的运用等。

    2022年9月5日
    4
  • USB调试助手_蓝牙串口APP

    USB调试助手_蓝牙串口APP今天终于把USB调试助手做完了,程序看起来自己还算满意,虽然有些地方还需完善,但整体功能已经实现了,程序就叫“USB调试助手”吧,是一款USB设备测试工具,可用于研究学习USB协议或进行USB设备开发测试使用,程序已经上传到CSDN了(https://download.csdn.net/download/donghailin/11965800),以方便大家下载,也希望大家提宝贵意…

    2022年9月3日
    2

发表回复

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

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