第一种方式: 把本地jar安装到本地maven仓库,然后在pom文件里面引入即可
mvn install:install-file -Dfile=D:\test\xxx.jar -DgroupId=com.demo -DartifactId=xxx -Dversion=1.0 -Dpackaging=jar
<dependency>
<groupId>com.demo</groupId>
<artifactId>xxx</artifactId>
<version>1.0</version>
</dependency>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>spingboot项目启动类的路径(com.demo.Start)</mainClass>
<outputDirectory>${project.basedir}</outputDirectory> jar包生成的路径
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
在根路径下,运行mvn clean package就可以在项目根路径下生成jar了,java -jar xxx.jar就可以运行jar了
第二种方法:项目根路径下面新建一个lib包,放入jar包,xxx.jar,在pom文件里面直接引入,groupId,artifactId和版本名字随便取
<dependency>
<groupId>com.xxx</groupId>
<artifactId>xxx</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/xxx.jar</systemPath>
</dependency>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
<mainClass>spingboot项目启动类的路径</mainClass>
<outputDirectory>${project.basedir}</outputDirectory>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
在项目根路径下,运行mvn clean package就可以在项目根路径下生成jar了,java -jar xxx.jar就可以运行jar了