SpringBoot项目打包 如何将本地文件打进war里 兼容性很好~

本文介绍了如何将本地jar包打包进SpringBoot的war文件中,包括在pom.xml中配置打包插件和指定jar路径,通过maven build完成打包,最终war文件位于项目target目录下。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

首先,找到你要导入的jar包的路径

我的在根目录的lib下
在这里插入图片描述

首先,需要在pom文件里面加入打包插件

      <plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-dependency-plugin</artifactId>
  <version>2.10</version>
  <executions>
    <execution>
      <id>copy-dependencies</id>
      <phase>compile</phase>
      <goals>
        <goal>copy-dependencies</goal>
      </goals>
      <configuration>
        <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/lib</outputDirectory>
        <includeScope>system</includeScope>
      </configuration>
    </execution>
  </executions>
</plugin>

在pom文件里面写入要导入的jar

注意格式要规范,不同插件格式不一样

<dependency>
<groupId>com.xxx</groupId>
<artifactId>xssprotest</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/xssProtect-0.1.jar</systemPath>
</dependency>

<dependency>
<groupId>com.xxx</groupId>
<artifactId>qrcode</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/QRCode.jar</systemPath>
</dependency>

最后maven build就好

在这里插入图片描述

导出的war在项目目录下的target里面

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值