spring boot打jar包独立出依赖库的方法 - zhouted/zhouted.github.io GitHub Wiki

<plugin>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-maven-plugin</artifactId>
  <configuration>
     <layout>ZIP</layout>
     <includes>
        <include><!-- 只包含自己 -->
            <groupId>cn.com.mine.groupid</groupId>
            <artifactId>mine-artifact</artifactId>
        </include>
    </includes> 
  </configuration>
</plugin>
<!-- 拷贝出依赖库 -->
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-dependency-plugin</artifactId>
  <executions>
    <execution>
      <id>copy</id>
      <phase>package</phase>
      <goals>
        <goal>copy-dependencies</goal>
      </goals>
      <configuration>
        <outputDirectory>
          ${project.build.directory}/lib
        </outputDirectory>
      </configuration>
    </execution>
  </executions>
</plugin>

启动时增加加载依赖包的路径

java -Dloader.path="lib/" -jar xxx.jar
⚠️ **GitHub.com Fallback** ⚠️