美文网首页Hello Java
上传第三方sdk到私服

上传第三方sdk到私服

作者: Aldeo | 来源:发表于2018-07-06 10:48 被阅读38次

在开发过程中项目之间的依赖可以通过deploy将依赖的项目上传到私服。但有时候项目需要引入第三方的sdk(但maven远程仓库没有更新,比如阿里的api),直接在ide中添加依赖肯定是不可取的,这时候就需要将第三方的sdk上传到私服,然后通过pom文件进行依赖配置。可以用两种方法,上传,第一种可以直接打开私服的管理页面进行上传(https://blog.csdn.net/alice_qixin/article/details/78390192),第二种是通过maven命令方法如下:

1.配置setting.xml文件确保私服配置正确

<?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">

  <!-- 
  本地仓库存储位置,默认为${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  -->

  <pluginGroups>

  </pluginGroups>  

  <proxies>

  </proxies>

  <!-- 发布的服务器及对应的用户名和密码-->
  <servers>   
    <server>  
        <id>releases</id>
        <username>admin</username>  
       <password>admin123</password>  
     </server>  
     <server>  
        <id>snapshots</id>  
        <username>admin</username>  
        <password>admin123</password>  
     </server>
    <server>  
        <id>thirdparty</id>  
        <username>admin</username>  
        <password>admin123</password>  
     </server>

  </servers>

  <mirrors>   
    <!-- 给nexus repository创建mirror镜像,-->
    <mirror>   
      <id>nexus</id>
      <mirrorOf>central</mirrorOf>   
      <url>http://192.168.33.107:8081/nexus/content/groups/public</url>   
    </mirror>   
    <!-- 配置其他镜像-->  
    <mirror>
      <id>alimaven</id>
      <name>aliyun maven</name>
      <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
      <mirrorOf>central</mirrorOf>        
    </mirror>
    <mirror>  
        <id>repo2</id>  
        <mirrorOf>central</mirrorOf>  
        <name>Human Readable Name for this Mirror.</name>  
        <url>http://repo2.maven.org/maven2/</url>  
    </mirror>
  </mirrors>

  <profiles>     
      <profile>  
        <id>nexus-profile</id>
        <activation>
          <jdk>1.7</jdk>
        </activation> 
        <repositories>  
          <!-- nexus仓库配置-->
          <repository>  
            <!-- repository唯一标识-->
            <id>nexus</id>  
            <!-- repository名称-->
            <name>local private nexus</name>  
            <!-- repository URL-->
            <url>http://192.168.33.107:8081/nexus/content/groups/public</url>  
            <!-- 表示可以从这个仓库下载releases版本的构件--> 
            <releases>
              <enabled>true</enabled>
            </releases>  
            <!-- 表示可以从这个仓库下载snapshots版本的构件--> 
            <snapshots>
              <enabled>true</enabled>
            </snapshots>  
          </repository>  
        </repositories> 
        <pluginRepositories>  
          <!-- nexus插件仓库配置-->
          <pluginRepository>  
            <id>nexus</id>  
            <name>local private nexus</name>  
            <url>http://192.168.33.107:8081/nexus/content/groups/public</url>  
            <releases>
              <enabled>true</enabled>
            </releases>  
            <snapshots>
              <enabled>true</enabled>
            </snapshots>  
          </pluginRepository>  
        </pluginRepositories>  
    </profile>    
  </profiles> 
  <!--激活私库信息的配置-->  
  <activeProfiles>  
      <activeProfile>nexus-profile</activeProfile>      
  </activeProfiles>  
</settings>

2.确保本地的maven已安装,在本地cmd窗口运行如下:

(1)将本地jar包安装到本地仓库

mvn install:install-file -DgroupId=taobao-sdk -DartifactId=taobao-sdk-java -Dversion=1479188381469 -Dpackaging=jar -Dfile=G:\dingdingMsgSDK\taobao-sdk-java-auto_1479188381469-20180702.jar

(2)将jar包上传到私服

mvn deploy:deploy-file -DgroupId=taobao-sdk -DartifactId=taobao-sdk-java-auto -Dversion=1479188381469-20180702 -Dpackaging=jar -Dfile=G:\dingdingMsgSDK\taobao-sdk-java-auto_1479188381469-20180702.jar -Durl=http://maven.long.com/nexus/content/repositories/releases -DrepositoryId=thirdparty

说明:

-Dfile指第三方jar的路径,其它的注意要确保maven命令中groupId、artifactId、version与pom.xml中的配置相同,-Dpackaging表示加载的文件类型 -DrepositoryId=需要与settings.xml中配置的server的id一致。

3.在pom文件引入如下即可自动更新私服上的jar包到本地仓库

<dependency>
    <groupId>taobao-sdk</groupId>
    <artifactId>taobao-sdk-java</artifactId>
    <version>1479188381469</version>
</dependency>

相关文章

  • 上传第三方sdk到私服

    在开发过程中项目之间的依赖可以通过deploy将依赖的项目上传到私服。但有时候项目需要引入第三方的sdk(但mav...

  • 手动上传第三方jar包到maven私服

    手动上传第三方jar包到maven私服 首先要知道maven私服的一些信息。由于账号密码我们是不知道,所以只能通过...

  • Docker 私服搭建使用实战

    官方指引 1. 搭建私服 演示图如下: 搭建后,即可通过浏览器访问私服,默认为空: 2. 上传镜像到私服 将私服连...

  • maven私服

    使用私服 Maven 自动打包上传到私服 Nexus 自动打包上传私服(nexus3.X版本改了很多) Repos...

  • Maven本地上传Nexus私服的两种方式

    1. 通过Web界面上传本地jar包到私服 登录配置好的私服地址(进入Nexus私服可视化界面) Views/Re...

  • Maven如何上传jar包到私服

    本文旨在介绍如何上传jar包到私服,关于如何安装maven、nexus私服请参考官网。 1、Maven简介 Apa...

  • maven上传源码到私服

    项目中经常碰到查看别人源码而没有,只能反编译的情况,是不是很痛苦? 所以 从自身做起,上传jar 给别人引用的时候...

  • 网易云视频点播SDK-集成梳理

    相关资料 官方文档 上传SDK-objc-sdk源码 上传SDK-java-sdk源码 iOS使用上传SDK介绍 ...

  • react-native第三方组件上传到npm仓库

    最近接到一个开发任务,将项目中的公共组件上传到私服上面。平常经常npm install 就将第三方组件下载下来了-...

  • 分布式组件(做成依赖版)

    我在做分布式组件时需要将写好的文件上传组件上传到maven私服,现在比较常用的maven私服有Artifacto...

网友评论

    本文标题:上传第三方sdk到私服

    本文链接:https://www.haomeiwen.com/subject/ognpuftx.html