如下图,工程里面引用了自定义的两个jar,目的:
1. 打jar
2.配置文件与jar和lib全部分离,方便下次更新jar以及随意更改配置文件
3. pom.xml中的
-
-
最终jar的名称 -
-
-
-
-
org.apache.maven.plugins -
maven-jar-plugin -
-
-
-
*.yml -
-
-
-
true -
-
lib/ -
-
false -
-
com.wenge.ShortVideoApplication -
-
-
-
./resources/ -
-
-
${project.build.directory}/out -
-
-
-
-
org.apache.maven.plugins -
maven-dependency-plugin -
-
- <id>copy-dependencies
-
package -
-
copy-dependencies -
-
-
- ${project.build.directory}/out/lib/
-
-
-
-
-
-
-
-
maven-resources-plugin -
-
- <id>copy-resources
-
package -
-
copy-resources -
-
-
-
-
src/main/resources -
*.yml -
-
-
${project.build.directory}/out/resources -
-
-
-
-
-
基于上面的,可以修改下面位置,逐一引入第三方jar
./resources/ ./jars/KwsExpConvert-1.1.jar/ ./jars/ZHConverter.jar
或者 (参考maven引入外部jar包的几种方式_像你这样的的博客-CSDN博客_maven打包引入外部jar包)
将本地jar安装到本地maven
- mvn install:install-file -Dfile=D:\GX_workspace\short-video\jars\KwsExpConvert-1.1.jar -DgroupId=com.wenge -DartifactId=expression -Dversion=0.1 -Dpackaging=jar
-
- mvn install:install-file -Dfile=D:\GX_workspace\short-video\jars\ZHConverter.jar -DgroupId=com.wenge -DartifactId=ZHConverter -Dversion=0.1 -Dpackaging=jar
然后,按照平时的引用,在pom.xml中添加
- <dependency>
- <groupId>com.wengegroupId>
- <artifactId>expressionartifactId>
- <version>0.1version>
- dependency>
- <dependency>
- <groupId>com.wengegroupId>
- <artifactId>ZHConverterartifactId>
- <version>0.1version>
- dependency>
这样打包就没问题了。
如果仅是自己使用,引用第三方jar
pom.xml中配置如下:
- <dependency>
- <groupId>com.wengegroupId>
- <artifactId>expressionartifactId>
- <scope>systemscope>
- <version>0.1version>
- <systemPath>${pom.basedir}/jars/KwsExpConvert-1.1.jarsystemPath>
- dependency>
- <dependency>
- <groupId>com.wengegroupId>
- <artifactId>ZHConverterartifactId>
- <scope>systemscope>
- <version>0.1version>
- <systemPath>${pom.basedir}/jars/ZHConverter.jarsystemPath>
- dependency>
基于上面的,如果不分离打包的话,直接在
- <plugin>
- <groupId>org.springframework.bootgroupId>
- <artifactId>spring-boot-maven-pluginartifactId>
- <executions>
- <execution>
- <id>repackageid>
- <goals>
- <goal>repackagegoal>
- goals>
- execution>
- executions>
- <configuration>
- <includeSystemScope>trueincludeSystemScope>
- configuration>
- plugin>
此文章仅限于自己总结使用