侧边栏壁纸
博主头像
SHO酱的Blog博主等级

行动起来,活在当下

  • 累计撰写 112 篇文章
  • 累计创建 149 个标签
  • 累计收到 3 条评论

目 录CONTENT

文章目录

Spring Boot 中使用 Maven 依赖本地 Jar 包,并在打包时引入

SHO酱
2021-12-29 / 0 评论 / 0 点赞 / 420 阅读 / 1504 字

步骤

  1. 在项目的目录中新建 lib 文件夹,并将 jar 包拷贝于此
  2. 在 pom 文件中设置依赖
<dependency>
    <groupId>cfca</groupId>
    <artifactId>****</artifactId>
    <version>5.3.7.1-sp1</version>
    <scope>system</scope>
    <systemPath>${project.basedir}/lib/****-5.3.7.1-sp1.jar</systemPath>
</dependency>
  1. 在 pom 文件中添加打包插件,以达到打包时引入外部依赖目的
<build>
    <finalName>${project.artifactId}</finalName>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <!--引入外部jar包 并配置  无此项外部jar打包时无法引入包中  -->
                <includeSystemScope>true</includeSystemScope>
            </configuration>
        </plugin>
    </plugins>
</build>

其中<includeSystemScope>true</includeSystemScope>尤为重要。

参考

spring boot 打包引入外部 jar 包

0

评论区