maven第三方引用终极方案

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>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值