1、新建POM文件,在maven库路径下创建POM文件
注意:这个路径需要与第2点导入命令中的grouoId、artifactId和version写法对应
Path:D:\RomanData\repository\com\sae\mail\1.0.0\mail-1.0.0.pom
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sae</groupId>
<artifactId>mail</artifactId>
<version>1.0.0</version>
<description>POM was created from install:install-file</description>
</project>
2、在项目的根目录下打开cmd窗口,执行命令
mvn install:install-file -DgroupId=com.sae -DartifactId=mail -Dversion=1.0.0 -Dpackaging=jar -Dfile=C:\Users\m088402\Desktop\mail.jar
3、导入成功,在项目pom.xml文件中引用依赖
<dependency>
<groupId>com.sae</groupId>
<artifactId>mail</artifactId>
<version>1.0.0</version>
</dependency>