SpringBoot打包时将lib放外面

步骤1: 正常编译JAR包,解压出lib文件夹

<build>
   <plugins>
       <plugin>
           <groupId>org.springframework.bootgroupId>
           <artifactId>spring-boot-maven-pluginartifactId>
           
           <configuration>
               <mainClass>org.joe.SystemApplicationmainClass>
               <layout>ZIPlayout>
               
           configuration>
       plugin>
   plugins>
build>
  • 打包命令:mvn clean install
  • 将Jar包解压,拷贝 BOOT-INF 目录下的lib文件夹 到目标路径;

步骤2: 编译打包不带 lib 文件夹的Jar包

<build>
  <plugins>
      <plugin>
          <groupId>org.springframework.bootgroupId>
           <artifactId>spring-boot-maven-pluginartifactId>
           
           <configuration>
               <mainClass>org.joe.SystemApplicationmainClass>
               <layout>ZIPlayout>
               
              
              <includes>
                  <include>
                      <groupId>nothinggroupId>
                      <artifactId>nothingartifactId>
                  include>
              includes>
              
          configuration>
      plugin>
  plugins>
build>
  • 打包:mvn clean install

步骤3: 运行编译后的Jar包

#-Dloader.path=lib文件夹路径

# 相对路径
java -Dloader.path=./lib -jar test123.jar
# 绝对路径
java -Dloader.path=/app/path/lib -jar test123.jar

你可能感兴趣的:(后端技术,环境,spring,boot,java,spring)