SpringBoot 打包第三方jar记录

42 阅读1分钟

背景

公司多模块的项目,需要打包一些第三方的jar到项目中去

方案

  1. 在模块目录下创建lib

截屏2022-07-08 下午4.05.40.png 2. 右键添加到classpath

截屏2022-07-08 下午4.07.33.png 3. 查看pom属性

截屏2022-07-08 下午4.06.57.png 4. pom文件中增加依赖

<dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpcomponents-asyncclient</artifactId>
    <version>4.0.2</version>
    <scope>system</scope>
    <systemPath>${pom.basedir}/lib/httpasyncclient-4.0.2.jar</systemPath>
</dependency>
  1. pom 文件中的resource模块增加下边设置,指定位置的jar打进包中
<resource>
    <directory>${pom.basedir}/lib</directory>
    <targetPath>BOOT-INF/lib/</targetPath>
    <includes>
        <include>**/*.jar</include>
    </includes>
</resource>
  1. 其他模块需要的话,可以在模块设置中增加进去