maven第三方引用终极方案
首先加入dependecy
<dependency>
<groupId>online.sanen</groupId>
<artifactId>cdm-core</artifactId>
<version>x.x.x</version>
<scope>system</scope>
<systemPath>${basedir}/lib/xxxxx.jar</systemPath>
</dependency>
Springmvc
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
springboot-jar
默认项目
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
</plugins>
</build>
如果想将第三方依赖和配置文件打包在jar外部
pom.xml文件中添加
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<archive>
<manifest>
<mainClass>com.esbk.isp.ISPApplication</mainClass> //指定Springboot程序启动类
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix> //指定依赖的jar包相对于本程序jar的位置
</manifest>
<manifestEntries>
<Class-Path>./</Class-Path>
</manifestEntries>
</archive>
<excludes>
<exclude>application*.yml</exclude> //指定打包时要排除的文件,支持正则
</excludes>
</configuration>
</plugin>
</plugins>
</build>
将项目依赖导出到指定文件夹
mvn dependency:copy-dependencies -DoutputDirectory=C:\Users\esbk\Desktop\lib -DincludeScope=runtime
springboot-tomcat
<resources>
<resource>
<directory>lib</directory>
<targetPath>${project.build.directory}/${project.name}-${project.version}/WEB-INF/lib/</targetPath>
<includes>
<include>*.jar</include>
</includes>
</resource>
</resources>