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即可。

相关推荐
文丑颜不良啊38 分钟前
LeetCode2821~2840题目解析
java·leetcode
apcipot_rain1 小时前
C++转Java日记(10)
java·开发语言
简 洁 冬冬2 小时前
泛型方法写法全面辨析:从「能编译」到「能跑」到「能用」
java·泛型
LGL6030A2 小时前
Java学习历程31——初识Spring Boot
java·spring boot·学习
Lansonli4 小时前
大数据Spark(八十八):Spark任务资源之Standalone集群测试
java·服务器·spark
budingxiaomoli4 小时前
Spring AOP
java·spring·java-ee
特立独行的猫A4 小时前
Ionic + 仓颉语言的 cj-tauri 开发框架实战:开发精美移动端 APP
java·后端·python
nice_lcj5205 小时前
LRU 缓存入门:它是什么、怎么用、面试怎么手写
java·数据结构·缓存·面试·lru
文丑颜不良啊6 小时前
LeetCode2741~2760题目解析
java·leetcode
金銀銅鐵15 小时前
带您看懂字节码指令(二):空循环里有什么
java·后端·ai编程