第一種方式: 把本地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了