maven:将jar制作成依赖导入maven私服

自己做了一个工具包 mytool-2.1.3.jar

(1)按照如下写法:

mvn install:install-file -DgroupId=mytool -DartifactId=com.example.demo -Dversion=2.1.3 -Dpackaging=jar -Dfile=D:\mytool-2.1.3.jar

命令行执行一下,有个别maven版本软件会报错,换个环境就行了,或者在linux下执行。

(2)成功后开始配置项目pom.xml

<dependency>

<groupId>mytool</groupId>

<artifactId>com.example.demo</artifactId>

<version>2.1.3</version>

</dependency>

(3)上传maven私服,在步骤一的执行结果中,告知了你的这个包存放在了哪个地方,从本地仓库根目录开始,取出安装好的包文件,保留目录结构。

(4)linux命令行导入maven私服,这里以nexus为例,一共两个脚本

脚本1 import.sh

bash 复制代码
#!/bin/bash
# copy and run this script to the root of the repository directory containing files
# this script attempts to exclude uploading itself explicitly so the script name is important
# Get command line params
while getopts ":r:u:p:" opt; do
    case $opt in
        r) REPO_URL="$OPTARG"
        ;;
        u) USERNAME="$OPTARG"
        ;;
        p) PASSWORD="$OPTARG"
        ;;
    esac
done
  
find . -type f -not -path './import\.sh*' -not -path '*/\.*' -not -path '*/\^archetype\-catalog\.xml*' -not -path '*/\^maven\-metadata\-local*\.xml' -not -path '*/\^maven\-metadata\-deployment*\.xml' | sed "s|^\./||" | xargs -I '{}' curl -u "$USERNAME:$PASSWORD" -X PUT -v -T {} ${REPO_URL}/{} ;

脚本2 start.sh

bash 复制代码
./import.sh -u admin -p 54123bd75 -r http://xxxxxx:80/repository/maven-repo/

两个脚本放一起,和步骤(3)取出的文件夹放在一起,配置账号密码,执行start.sh即可。

相关推荐
日月云棠5 分钟前
10 Integer —— 最常用的整数包装类深度解析
java·后端
秋910 分钟前
java项目中cpu飙升排查及解决方法
java·开发语言
野生技术架构师10 分钟前
牛客网2026最新大厂Java高频面试题精选(附标准答案)
java·开发语言
PH = 714 分钟前
JAVA的SPI机制
java·开发语言
一 乐15 分钟前
高校实习信息发布网站|基于Spring Boot的高校实习信息发布网站的设计与实现(源码+数据库+文档)
java·数据库·spring boot·后端·论文·毕设·高校实习信息发布网站
weelinking16 分钟前
【产品】11_实现后端接口——数据在背后如何流动
java·人工智能·python·sql·oracle·json·ai编程
摇滚侠24 分钟前
东方通替换tomcat,实战经验
java
utf8mb4安全女神1 小时前
【rsyslog服务】把所有服务的“临界点”以上的错误都保存在/var/log/alert.log⽇志中
java·前端·javascript
带刺的坐椅1 小时前
Solon Server 启动模式深度解析:从 0.3MB 内核到 10+ Server 插件
java·http·solon·jetty·undertow
郝学胜-神的一滴1 小时前
干货版《算法导论》07:递归视角下的选择排序与归并排序
java·数据结构·c++·python·程序人生·算法·排序算法