zoukankan      html  css  js  c++  java
  • nexus3添加第三方jar

    原文:http://www.cnblogs.com/yucongblog/p/6857318.html

    最近在看maven的打包及管理,然後就看到nexus,自己在安裝的時候就下載了最新版的nexus-3.2.0-01-win64,按照文档部署后启动,浏览。之前一致使用的是2.0的,所以还是需要导出点点,熟悉一下功能。

      熟悉2.0的都知道,那是可以上传自己的jar到库中,方便引用,但是3.0中,没有操作界面来上传jar,查阅3.0的文档,之找到一个上传Raw文件的方式,如下:

    复制代码
    复制代码
    16.5 Uploading Files to Hosted Raw Repositories

    Many other tools, besides using Maven, can be used to upload files to a hosted raw repository. A simple HTTP PUT can upload files. The following example uses the curl command and the default credentials of the admin user to upload a test.png file to a hosted raw repository with the name documentation.

    An Example Upload Command Using curl:

    curl -v --user ’admin:admin123’ --upload-file ./test.png http://localhost:8081/repository/documentation/test.png

    After a completed upload the repository manager provides the file at the URL http://localhost:8081/repository/documentation/test.png. Using this approach in a script entire static websites or any other binary resources can be uploaded.

    复制代码
    复制代码

      这段描述的是上传一个文件,如图片、html、js、css等等,上传到指定路径后,就可以通过url访问改资源。例如上传一个jQuery库文件,引用时只需添加url指向这个资源,而不需要在本地工程添加库文件,也可多个项目共享等等。

    但是,这个明显不是我想要的,继续寻找,最后在stackoverflow上面找到了答案:

    当nexus3为HTTP时,使用如下方式:

    如你需要上传utils-1.0.jar包,首先需准备新建一个pom.xml文件,内容如下:

    复制代码
    <project>
      <modelVersion>4.0.0</modelVersion>
      <groupId>org.foo</groupId>
      <artifactId>utils</artifactId>
      <version>1</version>
    </project>
    复制代码

    pom.xml和utils-1.0.jar两个文件放到一块就行,接下来使用命令上传到nexus上面:

    curl -v -u admin:admin123 --upload-file pom.xml http://localhost:8081/nexus/repository/maven-releases/org/foo/utils/1.0/utils-1.0.pom

    上传pom.xml文件到nexus上,并改名为utils-1.0.pom,注意你的release路径和包放的路径

    curl -v -u admin:admin123 --upload-file utils-1.0.jar http://localhost:8081/nexus/repository/maven-releases/org/foo/utils/1.0/utils-1.0.jar

    上传jar到相同路径下面。

      此时,utils-1.0.jar可以在maven工程的pom中使用了,我使用log4j-1.2.12.jar测试,这种方式可以。

    对于nexus设置为HTTPS的上传方法,我没测试,使用https的话需要配置的密匙文件,请看原文:http://stackoverflow.com/questions/38593513/how-to-upload-jar-to-nexus-oss-3

     注:我是在window10下面,使用的时Window Subsystem for Linux,在里面使用的curl上传的,也可自己下载curl.exe,如原文所说

  • 相关阅读:
    IE浏览器不能启动,双击启动图标无效
    提示Internet Explorer 9 已安装在此系统上,无法完成安装
    React项目跨域处理(两种方案)
    Mock数据模拟Node服务器
    【LeetCode】15. 3Sum
    【C++】int与string互转
    【LeetCode】37. Sudoku Solver
    【LeetCode】149. Max Points on a Line
    【LeetCode】104. Maximum Depth of Binary Tree (2 solutions)
    【LeetCode】140. Word Break II
  • 原文地址:https://www.cnblogs.com/shihaiming/p/6868627.html
Copyright © 2011-2022 走看看