• 首先用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

# To Be Continued!😎

Last Updated: 6/29/2021, 10:35:53 AM