方法1:
一 . 在项目根目录创建lib文件夹,把jar放入lib文件夹中
二 . 在项目中使用本地jar
pom文件配置如下:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<start-class>com.meeno.TrainsysApplication</start-class>
</properties>
<!--导入本地jar-->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>vod-upload</artifactId>
<version>1.4.11</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/aliyun-java-vod-upload-1.4.11.jar</systemPath>
</dependency>
<dependency>
<groupId>client-sdk</groupId>
<artifactId>api</artifactId>
<version>1.0.2</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/client-sdk.api-1.0.2.jar</systemPath>
</dependency>
<dependency>
<groupId>client-sdk</groupId>
<artifactId>common</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/client-sdk.common-1.0.0-SNAPSHOT.jar</systemPath>
</dependency>
<dependency>
<groupId>client-sdk</groupId>
<artifactId>core</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/client-sdk.core-1.0.0-SNAPSHOT.jar</systemPath>
</dependency>
<dependency>
<groupId>client-sdk</groupId>
<artifactId>example</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/client-sdk.example-1.0.0-SNAPSHOT.jar</systemPath>
</dependency>
<dependency>
<groupId>client-sdk</groupId>
<artifactId>spring</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/client-sdk.spring-1.0.0-SNAPSHOT.jar</systemPath>
</dependency>
<dependency>
<groupId>com.apache</groupId>
<artifactId>jodconverter</artifactId>
<version>2.2.2</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/jodconverter-2.2.2.jar</systemPath>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>taobao-sdk</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/taobao-sdk-java-auto_1479188381469-20170724.jar</systemPath>
</dependency>
说明:
dependency:名称随便
artifactId:名称随便
version:版本名称随便
scope:为system
systemPath:本地jar的路径,project.basedir为maven中的内置变量,表示当前项目根路径
三 . maven打包加入本地jar包
<!--本地jar打包时进入jar-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>${start-class}</mainClass>
<fork>true</fork>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>compile</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration> <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/lib</outputDirectory>
<includeScope>system</includeScope>
</configuration>
</execution>
</executions>
</plugin>
四 . 打包,clean清除一下,package打包
方法2:
pom
<!--导入本地jar-->
<dependency>
<groupId>com.arsoft.sdk</groupId>
<artifactId>arsoft-sdk-face</artifactId>
<version>3.0.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/arcsoft-sdk-face-3.0.0.0.jar</systemPath>
</dependency>
<!-- 下面是为了将本地jar包打入WEB-INF/lib下而增加的配置-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<webResources>
<resource>
<!-- 指向的是包含你所有要用jar包的目录 -->
<directory>${project.basedir}/lib</directory>
<!-- 编译后要把这些jar包复制到的位置 -->
<targetPath>WEB-INF/lib</targetPath>
</resource>
</webResources>
</configuration>
</plugin>