maven 打包引入本地 jar 包${project.basedir}/lib形式
[
spring-boot-maven-plugin打包 scope system 级别文件|本地 lib](https://www.notion.so/spring-boot-maven-plugin-scope-system-lib-1853459e7dca80e68580d1f1ab6e1816) 另一种方式,更省力一些
.
├── dependency-reduced-pom.xml
├── lib
│ └── top-schema-1.3.1.jar
├── pom.xml
├── src
│ ├── assembly
│ │ └── assembly.xml
│ ├── main
│ │ ├── java
│ │ │ └── org
│ │ │ └── example
│ │ │ └── Main.java
│ │ └── resources
│ └── test
│ └── java
├── target
│ ├── archive-tmp
│ ├── classes
│ │ ├── BOOT-INF
│ │ │ └── lib
│ │ │ └── top-schema-1.3.1.jar
│ │ └── org
│ │ └── example
│ │ └── Main.class
│ ├── generated-sources
│ │ └── annotations
│ ├── lib
│ │ └── top-schema-1.3.1.jar
│ ├── maven-archiver
│ │ └── pom.properties
│ ├── maven-status
│ │ └── maven-compiler-plugin
│ │ ├── compile
│ │ │ └── default-compile
│ │ │ ├── createdFiles.lst
│ │ │ └── inputFiles.lst
│ │ └── testCompile
│ │ └── default-testCompile
│ │ └── inputFiles.lst
│ ├── testTopSchema-1.0-SNAPSHOT-jar-with-dependencies.jar
│ └── testTopSchema-1.0-SNAPSHOT.jar
└── testTopSchema.iml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="<http://maven.apache.org/POM/4.0.0>"
xmlns:xsi="<http://www.w3.org/2001/XMLSchema-instance>"
xsi:schemaLocation="<http://maven.apache.org/POM/4.0.0> <http://maven.apache.org/xsd/maven-4.0.0.xsd>">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>testTopSchema</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.taobao</groupId>
<artifactId>top-schema</artifactId>
<version>1.3.1</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/top-schema-1.3.1.jar</systemPath>
</dependency>
</dependencies>
<build>
<!-- java -jar target/testTopSchema-1.0-SNAPSHOT.jar-->
<!-- java -jar target/testTopSchema-1.0-SNAPSHOT-jar-with-dependencies.jar-->
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>org.example.Main</mainClass>
</manifest>
<manifestEntries>
<Class-Path>.</Class-Path>
</manifestEntries>
</archive>
<!--<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>-->
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
<assembly>
<id>jar-with-dependencies</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<!-- 默认的配置 -->
<dependencySet>
<outputDirectory>/</outputDirectory>
<useProjectArtifact>true</useProjectArtifact>
<unpack>true</unpack>
<scope>runtime</scope>
</dependencySet>
<!-- 增加scope类型为system的配置 主要增加了scope类型为system的配置;这样在打包的时候,就会把本地jar也打包进去-->
<dependencySet>
<outputDirectory>/</outputDirectory>
<useProjectArtifact>true</useProjectArtifact>
<unpack>true</unpack>
<scope>system</scope>
</dependencySet>
</dependencySets>
</assembly>