Maven 打包本地jar 文件

282 阅读1分钟

遇到的问题

在一些情况下,项目需要引入本地jar包,但是在打包的时候,是打不进去的

如RXTX(串口开发)的引入

解决办法

一、maven 引入本地jar包

groupId、artifactId、version 自己输入,scope 必须是system,systemPath 实际jar包位置

<dependency>
    <groupId>gnu.io</groupId>
    <artifactId>RXTXcomm</artifactId>
    <version>1.0</version>
    <scope>system</scope>
    <systemPath>${java.home}/lib/ext/RXTXcomm.jar</systemPath>
</dependency>

一、允许springboot 的maven 插件包括系统范围

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <includeSystemScope>true</includeSystemScope>
            </configuration>
        </plugin>
    </plugins>
</build>