原文地址:https://my.oschina.net/xiaozhutefannao/blog/1932764
如只想jar分离可参考另一篇文档:https://blog.youkuaiyun.com/m0_37598340/article/details/86149186
参考文档处理时,一直出问题,稍微调整了一下出来了,我这个办法有点笨,模块较多的话会比较麻烦。
这边只列出调整了地方的配置文件
启动模块的pom.xml
<build>
<plugins>
<!-- 打出项目依赖的第三方包,放在lib下面(**相当于拷贝项目的jar包**) -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>target/lib</outputDirectory>
<excludeTransitive>false</excludeTransitive>
<stripVersion>false</stripVersion>
<includeScope>runtime</includeScope>
</configuration>
</execution>
</executions>
</plugin>
<!-- 项目中需要排除的模块-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<layout>ZIP</layout>
<excludes>
<!-- 项目中的模块配置 ,可添加多个-->
<exclude>
<groupId>xxxxxx</groupId>
<artifactId>aaaaaa</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
<!-- resources 排除了我们需要外置的文件(配置文件可以全部排除) -->
<resources>
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
<excludes>
<exclude>static/**</exclude>
<exclude>templates/**</exclude>
<exclude>*.yml</exclude>
<exclude>*.properties</exclude>
<exclude>*.xml</exclude>
<exclude>*.txt</exclude>
<exclude>dev_form_rule/**</exclude>
</excludes>
</resource>
</resources>
</build>
将target下lib包和test.jar(运行包)以及src/main/resources下你需要外置的文件部署至服务器同一目录下,如
启动时进入到启动jar的目录执行一下的命令
java -jar -Dloader.path=.,lib test.jar