Springboot+maven如何将外部lib包打入jar包

392 阅读1分钟

我不知道原理但是实现了我想要的结果,但我不知道原理这不是我想要的结果。

开发一个串口通信项目时需要使用到RXTXcomm.jar,出现问题:如何在打jar包时将外部lib包一起打进去。

  • 引入依赖
<dependency>
           <groupId>gun.io</groupId>
           <artifactId>RXTXcomm</artifactId>
           <version>1.0.0</version>
           <!-- 你的包的路径 -->
           <systemPath>${project.basedir}/lib/RXTXcomm.jar</systemPath>
           <scope>system</scope>
</dependency>
  • spring-boot-maven-plugin中加入配置
<includeSystemScope>true</includeSystemScope>
  • 打包资源路径
<resource>
    <directory>lib</directory>
    <targetPath>WEB-INF/lib/</targetPath>
    <includes>
        <include>**/*.jar</include>
    </includes>
</resource>