首先用
mvn clean package
正常打出jar包,将jar包解压,将BOOT-INF
下的lib
包拿出单独存放修改pom.xml的build配置
<!--修改前-->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<!--微服务模式下修改为true,跳过此打包插件,否则微服务模块无法引用-->
<skip>false</skip>
</configuration>
</plugin>
</plugins>
</build>
<!--修改后-->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<layout>ZIP</layout>
<includes>
<include>
<groupId>nothing</groupId>
<artifactId>nothing</artifactId>
</include>
</includes>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
- 运行jar包,其中
/javalib
是lib中jar包的存放路径
java -Dloader.path=/javalib -jar app.jar