当前位置: 首页 > news >正文

spring boot源码和lib分开打包

1.项目通过maven引入的jar多了之后,用maven打出的jar会非常庞大,我的是因为引入了ffmpeg的相关jar,所以,每次上传服务更新都要传输好久,修改maven打包方式,改为源码和lib分离模式
2.maven的pom.xml配置如下

<build><plugins><!-- Step 1: 只打包源码(不包含依赖) --><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-jar-plugin</artifactId><version>3.4.0</version><configuration><archive><manifest><mainClass>com.xxx.springboot.xxxxxApplication</mainClass> <!-- 替换为你自己的主类 --><addClasspath>true</addClasspath><classpathPrefix>lib/</classpathPrefix></manifest><manifestEntries><!-- 不上maven管理的jar引入方式 --><Class-Path>lib/DmJdbcDriver18-1.0.jar lib/encrypt-body-spring-boot-starter-1.2.3.jar</Class-Path></manifestEntries></archive></configuration></plugin><!-- Step 2: 使用 spring-boot-maven-plugin 打包并提取依赖到 lib/ --><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><executions><execution><id>repackage</id><goals><goal>repackage</goal></goals><configuration><skip>true</skip> <!-- 禁用默认 repackage --></configuration></execution><execution><id>build-info</id><goals><goal>build-info</goal></goals></execution></executions></plugin><!-- Step 3: 提取依赖到 target/lib/ --><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><!-- Step 4 (可选): 创建最终发布的 dist 文件夹 --><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-antrun-plugin</artifactId><executions><execution><phase>package</phase><goals><goal>run</goal></goals><configuration><target><mkdir dir="${project.build.directory}/dist"/><copy file="${project.build.directory}/${project.build.finalName}.jar"tofile="${project.build.directory}/dist/chenzhou.jar"/><copy todir="${project.build.directory}/dist/lib"><fileset dir="${project.build.directory}/lib"/></copy></target></configuration></execution></executions></plugin></plugins></build>

3.对于非maven仓库中的包处理方式

<!-- 非maven仓库包 -->
<dependency><groupId>com-dm</groupId><artifactId>DmJdbcDriver18</artifactId><version>1.0</version><scope>system</scope><systemPath>${project.basedir}/lib/DmJdbcDriver18.jar</systemPath>
</dependency>
<!-- 指定jar位置,多个以空格分开,对于不上版本结尾的名称,打包放入lib后会自动增加1.0,所以,引入jar写入也要增加 
例如:达梦数据库驱动包,项目实际引入DmJdbcDriver18.jar
在Class-Path中的配置要为:DmJdbcDriver18-1.0.jar
-->
<manifestEntries><Class-Path>lib/DmDialect-for-hibernate6.1-1.0.jar lib/DmJdbcDriver18-1.0.jar</Class-Path>
</manifestEntries>

如有不妥之处,请谅解!

http://www.xdnf.cn/news/986527.html

相关文章:

  • 遍历 unordered_map
  • GFS 分布式文件系统
  • UE_Event Any Damage和OnTake Any Damage
  • JAVA CAS 详解
  • Docker完整教程 - 从入门到SpringBoot实战
  • JSON5 模块的作用与区别
  • 图标异常问题
  • 【Linux】进程控制(下)---程序替换宝藏岛
  • 如何排查PHP-FPM进程CPU占用100%的间歇性问题 (2025)
  • Unity 服务器交互开发指南
  • 基于RocketMQ源码理解顺序写、刷盘机制与零拷贝
  • 海康对接摄像头
  • Chromium 136 编译指南 Windows篇:获取源代码(五)
  • 基于贝叶斯学习方法的块稀疏信号压缩感知算法
  • Spring核心框架完全指南 - 基础知识全解析
  • 关于界面存在AB测试后UI刷新空白的问题
  • 计算机网络 : 传输层协议UDP与TCP
  • 设计原则——KISS原则
  • 过拟合和欠拟合
  • RAG技术全解析:从概念到实践,构建高效语义检索系统——嵌入模型与向量数据库搭建指南
  • java每日精进 6.11【消息队列】
  • C++11的特性上
  • Cursor 编程实践 — 开发环境部署
  • 案例8 模型量化
  • 使用MyBatis-Plus实现数据权限功能
  • 【Unity3D优化】优化多语言字体包大小
  • swagger通过配置将enum自动添加到字段说明中
  • PHP如何检查一个字符串是否是email格式
  • 【微信小程序】| 在线咖啡点餐平台设计与实现
  • 华为云Flexus+DeepSeek征文 | 基于华为云ModelArts Studio打造AingDesk AI聊天助手