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


相关推荐

  • Ubuntu16.04 完全卸载cuda

    Ubuntu16.04 完全卸载cudasudoapt-get–purgeremovecuda-*

    2022年6月17日
    26
  • 一阶惯性滤波特点_一阶惯性环节仿真

    一阶惯性滤波特点_一阶惯性环节仿真由文章(二)可知,二次平均法改善了一次平均法滤除低频干扰时超调的影响,但仍然未能完全滤除低频干扰。因此,通过改变反馈控制系统参数结合平均法是一个不错的选择,仿真如图:通过改变比例系数,可以实现一定的滤波效果,此方法是通过降低响应参数的方式实现一级滤波,通过平均法实现二级滤波,仿真结果如下图:文章《一阶惯性传感器的快速跟踪性能实现》中,最终传递函数为:本例中,传递函数为启动性能与文章《一阶惯性传感器的快速跟踪性能实现》中接近,且较大地滤除了高频、低频干扰可见,该控制

    2022年10月4日
    3
  • phpstorm Mac 激活码(注册激活)

    (phpstorm Mac 激活码)本文适用于JetBrains家族所有ide,包括IntelliJidea,phpstorm,webstorm,pycharm,datagrip等。https://javaforall.net/100143.htmlIntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,上面是详细链接哦~M…

    2022年3月20日
    289
  • python 递归深度

    python 递归深度python对于递归深度有默认的设置,当递归层数过深,超过1000时,会报错RecursionError:maximumrecursiondepthexceededwhilecallingaPythonobject可以通过如下设置:importsyssys.setrecursionlimit(1200)手动设置递归深度,测试后发现,最大上限在8

    2022年6月22日
    68
  • 使用u盘之前需要将其格式化_使用g中的光盘之前需要将其格式化

    使用u盘之前需要将其格式化_使用g中的光盘之前需要将其格式化本人使用一个外置硬盘,结果每次下载东西都需要重新格式化,从网上找了下方法,发现Windows有自动修复的工具,不用每次格式化。1.首先进入运行,保证自己管理员模式,通过"Windows键+

    2022年8月6日
    6
  • [转]我如烟的世界里曾飘落幻美的花

    [转]我如烟的世界里曾飘落幻美的花

    2021年7月24日
    61

发表回复

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

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