1. 背景
工作需要,须引入非Maven中央仓库的jar包。
2. 引入
2.1 目标服务下新建lib目录,与src同级,放入需引入的jar包
2.2 pom.xml文件
2.2.1 dependency
groupId可以随便写,${basedir}不需要定义
<!-- gmhelper -->
<dependency>
<groupId>com.test</groupId>
<artifactId>gmhelper</artifactId>
<version>1.31</version>
<scope>system</scope>
<systemPath>${basedir}\lib\gmhelper-1.31.jar</systemPath>
</dependency>
2.2.2 configuration
这一步是必要的,否则打包出来的MANIFEST文件中没有该jar,启动时找不到所需类,会报错
<build>
<plugins>
<plugin>
<configuration>
<archive>
<manifestEntries>
<!--MANIFEST.MF中Class-Path加入资源文件目录,不需要配置,在外部命令行指定-->
<Class-Path>./resources ./lib/gmhelper-1.31.jar</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
2.3 上线
上线时需要将jar包手动上传至线上服务器的lib包中
3. 补充:关于MANIFEST.MF的位置
在打包出来的jar解压后的META-INF文件中