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


相关推荐

  • 电脑apk文件怎么打开_python pkl文件

    电脑apk文件怎么打开_python pkl文件importpickledoc=open(r’D:\dataset\st_gcn_processed_data\data\NTU_RGB_D\xview\val_label.txt’,’a’)#打开一个存储文件,并依次写入test=open(r’D:\dataset\st_gcn_processed_data\data\NTU_RGB_D\xview\val_label.pkl’,’rb’)data=pickle.load(test)print(data,file=doc).

    2025年8月26日
    6
  • android 自定义控件 attrs,android 使用attrs自定义控件

    android 自定义控件 attrs,android 使用attrs自定义控件步骤:1、在values下新建一个attrs.xml的资源文件(my_attrs.xml)//===》name为引用资源的名称//attr中的name为自定义的名称format为类型//字体颜色//字体大小//字符串2、新建一个类MyAttrsMyView继承View覆写publicMyAttrsMyView(Contextcontext,Attribu…

    2022年10月17日
    1
  • linux的进程调度指的是系统对进程调用_Linux进程调度实验

    linux的进程调度指的是系统对进程调用_Linux进程调度实验进程状态进程调度就是让进程从一种状态切换到另一种状态。Linux中进程的主要状态如下,值状态缩写含义0TASK_RUNNINGR正在运行或可运行1TASK_INTERRUPTIBLES可中断的休眠2TASK_UNINTERRUPTIBLED不可中断的休眠4__TASK_STOPPEDT停止状态,当进程接收到SIGSTOP等signal信息8__TASK_TRACEDt跟踪状态,进程被debugge…

    2022年9月28日
    3
  • APP稳定性测试_APP测试

    APP稳定性测试_APP测试APP稳定性测试概念指软件长时间的持续运行,系统版本是否稳定,是否能否持续的为用户提供服务测试指标异常的次数异常的频率测试工具MonkeyMonkey是向系统发送随机的用户事件流(如按键输入、触摸屏输入和手势输入等),实现对正在开发的应用程序进行稳定性测试。可以更好的模拟用户操作,确保App的稳定性。  通过Monkey程序模拟用户触摸屏幕、滑动Trackball、按键等操作来对设备上的程序进行压力测试,检测程序多久的时间会发生异常Monkey原理Monk.

    2025年10月14日
    4
  • 路由器有线桥接的两种方式异同

    路由器有线桥接的两种方式异同根据这篇文章 http www gezila com tutorials 46010 html 我小结下两种方式之要点及异同另主路由器为路由器 A 副路由器为路由器 B 方式一 LAN WAN1 A 的 LAN 口接到 B 的 WAN 口 2 B 的以太网接入方式 WAN 口接入类型 选择动态 ip 这个 ip 实质是由 A 的 DHCP 服务分配的 如图 可见 A 给 B 分配的 ip 地

    2025年6月17日
    6
  • 力扣算法题—060第K个排列

    力扣算法题—060第K个排列

    2021年7月4日
    131

发表回复

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

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