spring boot使用nexus私服上传和下载jar包的配置

1.修改maven的setting文件,即可拉取私服jar包

<?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>E:\myWork\maven\myRepository</localRepository>
 
  <pluginGroups>
  </pluginGroups>


  <proxies>
  </proxies>


  <servers>
	 <!--第一个nexus-wang要和下面的mirror中的id一致,代表拉取是也需要进行身份校验-->
    <server>
      <id>nexus-ttheng</id>
      <username>admin</username>
      <password>ttheng123</password>
    </server>
	<!--这两个是jar上传时候进行的验证,id对应的是pom中id属性的值-->
	<server>
      <id>releases</id>
      <username>admin</username>
      <password>ttheng123</password>
    </server>
	<server>
      <id>snapshots</id>
      <username>admin</username>
      <password>ttheng123</password>
    </server>
    
  </servers>


  <mirrors>
	<mirror>
		<id>nexus-ttheng</id>
		<mirrorOf>*</mirrorOf>
		<name>internal nexus repository</name>
		<url>http://127.0.0.1:8081/repository/ttheng-maven-public/</url>
	</mirror>
  </mirrors>

  <profiles>
	<profile>
		<!--ID用来确定该profile的唯一标识-->
	   <id>jdk-1.8</id>
	   <activation>
		   <activeByDefault>true</activeByDefault>
		   <jdk>1.8</jdk>
	   </activation>
	   <properties>
		   <maven.compiler.source>1.8</maven.compiler.source>
		   <maven.compiler.target>1.8</maven.compiler.target>
		   <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
	   </properties>
	</profile>
	
	<profile>
	  <id>nexus-pr</id>
	   <!-- 远程仓库列表 -->
	  <repositories>
		<repository>
		  <id>nexus</id>
		  <name>Nexus Central</name>
		 <!-- 虚拟的URL形式,指向镜像的URL-->
		  <url>http://127.0.0.1:8081/repository/ttheng-maven-public/</url>
		  <layout>default</layout>
		 <!-- 表示可以从这个仓库下载releases版本的构件-->  
		  <releases>
			<enabled>true</enabled>
		  </releases>
		 <!-- 表示可以从这个仓库下载snapshot版本的构件 -->  
		  <snapshots>
			<enabled>true</enabled>
		  </snapshots>
		</repository>
	  </repositories>
	  
	  
	   <!-- 插件仓库列表 -->
	  <pluginRepositories>
		<pluginRepository>
		  <id>nexus</id>
		  <name>Nexus Central</name>
		  <url>http://127.0.0.1:8081/repository/ttheng-maven-public/</url>
		  <layout>default</layout>
		  <snapshots>
			<enabled>true</enabled>
		  </snapshots>
		  <releases>
			 <enabled>true</enabled>
		  </releases>
		</pluginRepository>
	  </pluginRepositories>
	</profile>

  </profiles>

   <!--需要激活 <profile>中的ID才生效-->
  <activeProfiles>
    <activeProfile>nexus-pr</activeProfile>
    <activeProfile>jdk-1.8</activeProfile>
  </activeProfiles>
  
</settings>

2.修改springboot工程的pom文件,即可打包上传到私服

<!-- 使用分发管理将本项目打成jar包,直接上传到指定服务器 -->
    <distributionManagement>
<!-- 正式版 -->
        <repository>
<!-- nexus服务器中用户名:在settings.xml中<server>的id一致-->
            <id>releases</id>
            <name>Release repository</name>
            <url>http://127.0.0.1:8081/repository/ttheng-maven-releases/</url>
        </repository>
<!-- 快照 -->
        <snapshotRepository>
<!-- nexus服务器中用户名:在settings.xml中<server>的id一致-->
            <id>snapshots</id>
            <name>Snapshots repository</name>
            <url>http://127.0.0.1:8081/repository/ttheng-maven-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>

 

参考:https://blog.csdn.net/wc1695040842/article/details/102575686

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值