需求描述

由于公司 SDK 没有正式上线,只能提供 jar,需要手动添加依赖,在使用 maven 打包的时候提示找不到符号。

解决方案

将外部 jar 使用 maven 管理

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<dependency>
<!-- 因为实际不会从远程仓库下载,因此坐标可以填写任意值 -->
<groupId>任意值</groupId>
<artifactId>任意值</artifactId>
<version>任意值</version>
<!-- scope 必须是 system,表明是从本地读取信息 -->
<scope>system</scope>
<systemPath>项目中的相对路径</systemPath>
</dependency>

<!-- 额外配置,
默认情况下,外部依赖只会在编译时加载,打包后会丢失,
需要增加以下配置
-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<!-- includeSystemScope 开启即可-->
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>

评论