springboot引入本地jar包

发布时间 2023-11-18 17:03:12作者: xl4ng

1. 在resources目录下新建lib目录,将jar放入

2. 在pom文件中添加依赖

<dependency>
    <groupId>com.fanruan</groupId>
    <artifactId>fine-accumulator</artifactId>
    <version>11.0</version>
    <scope>system</scope>
    <systemPath>${pom.basedir}/src/main/resources/lib/fine-accumulator-11.0.jar</systemPath>
</dependency>

3. 配置build插件includeSystemScope为true

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>2.1.1.RELEASE</version>
            <configuration>
                <fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
                <includeSystemScope>true</includeSystemScope>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
</build>