Nexus private server warehouse imports local jars in batches

Nexus private server batch import local library

My last article: nexus download & installation & warehouse use:
https://blog.csdn.net/weixin_42717648/article/details/98206733
Part of this article is reproduced from: Nexus3.x batch import local library:
https://blog. csdn.net/u014468095/article/details/87261817


insert image description hereSelect maven2(hosted) in the click order as shown in the figure
insert image description here

Fill in the following options according to your own needs,
insert image description hereinsert image description here
click Create repository
and then you can see our newly created warehouse on the page,
insert image description hereclick to enter, see the URL of the warehouse, write down
insert image description herea new folder repo in the user's home directory, and put it in batches we need
insert image description here
Create a new shell script in the local library folder.
insert image description here
The content of the script is as follows:

#!/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 './mavenimport\.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}/{} ;

Give the script executable permissions.
./mavenimport.sh -u admin -p admin123 -r http://your ip:your port/repository/my repo/

Note: If mavenimport.sh is imported into Linux after editing in Windows, there will be problems
insert image description here . Use vi mavenimport.sh to enter and execute at the bottom: set ff to see the format of .sh.
What is the reason? We have reason to suspect that it is a file format problem? We use vim mavenimport.sh to enter the mavenimport.sh file, and then in the bottom mode, execute: set ff to check, and found that fileformat=dos, look, it really is a file format problem, how to solve it?

 方法一:vim mavenimport.sh进入mavenimport.sh后, 在底部模式下, 执行:set fileformat=unix后执行:x或者:wq保存修改。 然后就可以执行./mavenimport.sh运行脚本了。(我亲自试过, 是ok的)
 方法二:直接执行sed -i "s/\r//" mavenimport.sh来转化, 然后就可以执行./mavenimport.sh运行脚本了。(我亲自试过, 是ok的)
 方法三:直接执行dos2unix mavenimport.sh来转化, 然后就可以执行./mavenimport.sh运行脚本了。(我的linux上执行dos2unix ./mavenimport.sh失败, 但是不要放弃啊, 加个busybox就可以了), 

When you are done, execute it again and press
Enter to run it.
insert image description hereinsert image description here
The above is a process of importing jars in batches. I hope it can help you. The next article will show you how to connect maven to nexus and how to configure it in the pom file.

String later ="稍后";
String never = "永不";
if(later == never ){
	throw new RunTimeException();
} else {
	log.info("壮丽明天等着你!!!");
}

I hope that the life code will not report an error.

Guess you like

Origin blog.csdn.net/weixin_42717648/article/details/98213700