Maven 添加本地依赖包
- 在项目根目录添加lib文件夹,存放不在maven仓库中存在的jar包
如下两个推送包,(名字可以自定义)
//华为推送服务端jar包
HwPush_SDK_Server_0_3_12.jar
//小米推送服务端jar包
MiPush_SDK_Server_2_2_18.jar
- 在pom.xml中添加依赖
<dependency>
<groupId>com.xiaomi</groupId>
<artifactId>MiPush_SDK_Server_2_2_18</artifactId>
<version>2.2.18</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/MiPush_SDK_Server_2_2_18.jar </systemPath>
</dependency>
<!-- 华为推送 -->
<dependency>
<groupId>com.huawei.hms</groupId>
<artifactId>HwPush_SDK_Server_0_3_12</artifactId>
<version>0.3.12</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/HwPush_SDK_Server_0_3_12.jar</systemPath>
</dependency>
- 在SpriingBoot中将本地jar包打包到项目的jar包里,需要build中添加如下内容:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<!-- 指定SpringBoot程序的main函数入口类 -->
<mainClass>com.redsoft.epip.EPIPApplication</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<compilerArguments>
<!-- 打包本地jar包 -->
<extdirs>${project.basedir}/lib</extdirs>
</compilerArguments>
</configuration>
</plugin>
</plugins>
<!-- 打包所有jar包 -->
<resources>
<resource>
<directory>lib</directory>
<targetPath>BOOT-INF/lib/</targetPath>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
<!-- 某些情况下,打包后运行不起来需要打开注释 -->
<!-- <resource>
<directory>src/main/resources</directory>
<targetPath>BOOT-INF/classes/</targetPath>
</resource> -->
</resources>
</build>
执行package命令后即可将本地jar包打进去