Maven adds dependencies to local jar packages
use two methods
One is to use the idea tool to directly package the written project using the "Install" command and then install it into the local library; the other
is to install it into the local library through the local cmd command.
Package the written method or project, use the idea tool to package it directly and put it into the local maven warehouse
During the packaging process, the path of the package will be output on the console, and then follow the path to find the location just packaged.
Reference the package and add dependencies directly to the pom in the new project
<dependency>
//文件夹名
<groupId>org.example</groupId>
//包名
<artifactId>myutils</artifactId>
<version>1.0</version>
</dependency>
test
public class Tsetmytuils {
public static void main(String[] args) {
Mypf my = new Mypf();
System.out.println(my.pf(33));//1089
}
}
Use cmd to package in the command console and put it into the local warehouse
First find the file package and copy it out. Put it here on the E drive
Then open cmd in the search box of the E disk and enter the following command
Among them, DgroupId can be changed by itself, so that it can be found in the warehouse
mvn install:install-file -Dfile=myutils-1.0.jar -DgroupId=org.example -DartifactId=myutils -Dversion=1.0 -Dpackaging=jar
execution succeed
View in local maven repository
Test: Click Refresh in the test project just now, and then it will be loaded without error
cDgw0R-1673682572535)]
Test: Click Refresh in the test project just now, and then it will be loaded without error