maven加载外部jar包

maven加载外部jar包

在这里插入图片描述

pom文件

<!-- scope为system时,自动添加lib依赖包 -->
<dependency>
    <groupId>FFmpeg</groupId>
    <artifactId>FFmpeg</artifactId>
    <version>1.0</version>
    <scope>system</scope>
    <systemPath>${basedir}/src/main/resources/lib/hk/FFmpeg-1.0.jar</systemPath>
</dependency>
<dependency>
    <groupId>examples</groupId>
    <artifactId>examples</artifactId>
    <version>1.0</version>
    <scope>system</scope>
    <systemPath>${basedir}/src/main/resources/lib/hk/examples.jar</systemPath>
</dependency>
<dependency>
    <groupId>jna</groupId>
    <artifactId>jna</artifactId>
    <version>1.0</version>
    <scope>system</scope>
    <systemPath>${basedir}/src/main/resources/lib/hk/jna.jar</systemPath>
</dependency>
  <dependency>
      <groupId>com.xx.xxx</groupId> //组织,随便命名
      <artifactId>***</artifactId> //包的名字,随便命名
      <version>1.0.0</version> //版本,随便命名
      <scope>system</scope>  //scope为system时,自动添加lib依赖包
      <systemPath>${basedir}/src/main/resources/lib/**.jar</systemPath> //路径,这里我jar在resources目录的lib文件夹下,也可以放在跟目标,路径按需修改
 </dependency>

项目打包问题

是由于项目打包时,不识别外部jar,又没有进行配置,继而导致出现问题。

  <plugin>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-maven-plugin</artifactId>
       <configuration>
             <includeSystemScope>true</includeSystemScope>
       </configuration>
  </plugin>

版权声明:本文为weixin_43296313原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。