补习系列-springboot-使用assembly进行项目打包
目录
- springboot-maven插件
- 1. 项目打包Jar
- 2. 项目完整构建
- 3. 本地包依赖
- 参考文档
springboot-maven插件
springboot-maven插件
repackage目标声明
Requires a Maven project to be executed.
Requires dependency resolution of artifacts in scope: compile+runtime.
Since version: 1.1.
Binds by default to the lifecycle phase: package.
1. 项目打包Jar
<build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><executions><execution><goals><goal>repackage</goal></goals></execution></executions></plugin></plugins></build>
如此,执行mvn package可自动生成一个独立可执行的jar文件
2. 项目完整构建
通常,项目发布时除了jar包,还会包含配置文件、启停脚本等,此时需要借助assembly插件完成重复打包
构建结构
base- bin- start.sh- stop.sh- application.properties- log4j.properties- app-0.0.1-SNAPSHOT.jar
pom定义
<build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><executions><execution><goals><goal>repackage</goal></goals></execution></executions></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-assembly-plugin</artifactId><version>2.4</version><executions><execution><id>bundle</id><phase>package</phase><goals><goal>single</goal></goals><configuration><descriptors><descriptor>${basedir}/src/main/build/assembly.xml</descriptor></descriptors></configuration></execution></executions></plugin></plugins></build>
说明
将assembly定义在spring-boot:repackage之后,这样maven在执行package阶段时会按照声明顺序处理;
assembly.xml存放于src/main/build目录,此外用于发布的config、bin目录及文件都放到这个目录;
assembly定义
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd"><id>bundle</id><formats><format>tar.gz</format></formats><includeBaseDirectory>false</includeBaseDirectory> <!-- disable the creation of root's distribution dir in the archive --><fileSets> <!-- config files --><fileSet> <directory>${basedir}/src/main/build/config</directory> <excludes></excludes> <includes><include>application*.properties</include><include>log4j.properties</include> </includes><fileMode>0644</fileMode><outputDirectory>/</outputDirectory> </fileSet> <!-- scripts --><fileSet><directory>${basedir}/src/main/build/bin</directory><includes><include>*.sh</include></includes><fileMode>0755</fileMode><outputDirectory>/</outputDirectory></fileSet><!-- executable jar --><fileSet><directory>${project.build.directory}</directory><outputDirectory>/</outputDirectory><includes><include>${project.artifactId}-${project.version}.jar</include></includes><fileMode>0755</fileMode></fileSet></fileSets> </assembly>
关于内置变量
3. 本地包依赖
- 定义scope=system依赖
<dependency><groupId>com.xxx.component</groupId><artifactId>mongoop</artifactId><version>0.0.1-SNAPSHOT</version><scope>system</scope><systemPath>D:\work\maven\repo\m2\xxx.jar</systemPath></dependency>
- 声明springboot打包时包含system范围的依赖
<build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><configuration><includeSystemScope>true</includeSystemScope></configuration><executions><execution><goals><goal>repackage</goal></goals></execution></executions></plugin></plugins></build>
参考文档
springboot文档-maven插件使用
关于springboot-repackage
maven内置变量
作者:zale
补习系列-springboot-使用assembly进行项目打包相关推荐
- SpringBoot使用assembly进行项目定制化打包
SpringBoot使用assembly进行项目定制化打包 一.项目配置 1.添加插件 (1)编辑项目的 pom.xml 文件,加入 assembly 打包插件: <build><p ...
- 解决springboot maven多模块项目打包的时候某个被依赖的模块报错找不到main class
springboot maven 多模块项目打包的时候某个被依赖的模块报错 [ERROR] Failed to execute goal org.springframework.boot:spring ...
- SpringBoot+Dubbo+Zookeeper分布式项目打包时子模块依赖找不到解决方案
我的个人网站:等不见天亮等时光 问题描述:子模块打包依赖其他的子模块,打包显示找不到jar包 解决方案:由于springboot打包和maven打包最后出来的jar包不同需要在pom中新增以下插件 & ...
- 补习系列- springboot 整合 shiro 一指禅
目标 了解ApacheShiro是什么,能做什么: 通过QuickStart 代码领会 Shiro的关键概念: 能基于SpringBoot 整合Shiro 实现URL安全访问: 掌握基于注解的方法,以 ...
- 补习系列-SpringBoot 整合Shiro 一指禅
目标 了解ApacheShiro是什么,能做什么: 通过QuickStart 代码领会 Shiro的关键概念: 能基于SpringBoot 整合Shiro 实现URL安全访问: 掌握基于注解的方法,以 ...
- 补习系列(1)-springboot项目基础搭建课
目录 前言 一.基础结构 二.添加代码 三.应用配置 四.日志配置 五.打包部署 小结 前言 springboot 最近火的不行,目前几乎已经是 spring 家族最耀眼的项目了.抛开微服务.技术社区 ...
- 补习系列(19)-springboot JPA + PostGreSQL
目录 SpringBoot 整合 PostGreSQL 一.PostGreSQL简介 二.关于 SpringDataJPA 三.整合 PostGreSQL A. 依赖包 B. 配置文件 C. 模型定义 ...
- 补习系列(18)-springboot H2 迷你数据库
目录 关于 H2 一.H2 用作本地数据库 1. 引入依赖: 2. 配置文件 3. 样例数据 二.H2 用于单元测试 1. 依赖包 2. 测试配置 3. 测试代码 小结 关于 H2 H2 数据库是一个 ...
- 补习系列(17)-springboot mongodb 内嵌数据库
目录 简介 一.使用 flapdoodle.embed.mongo A. 引入依赖 B. 准备测试类 C. 完善配置 D. 启动测试 细节 二.使用Fongo A. 引入框架 B. 准备测试类 C.业 ...
最新文章
- LeetCode 804	Unique Morse Code Words--python,java解法
- apollo芯片_ADAS/AD主控芯片研究:集成趋势下的短板与变革
- python爬取app中的音频_Python爬取抖音APP,只需要十行代码
- 是引进外部函数吗_使用PowerBI的这两个函数,灵活计算各种占比
- 面试基础算法、及编程 第一弹
- Java描述设计模式(09):装饰模式
- POJ 1002 487-3279
- 《基于MFC的OpenGL编程》Part 14 Quadrics
- 开源机器学习工具SQLFlow
- IOS开发自定义tableviewcell的注意点
- EditPlus Version 3 价格 代理商 销售价格 正版软件价格
- UE编辑器 添加注释选区的快捷键
- 简单工厂、工厂方法、抽象工厂区别
- 一个分块矩阵求逆矩阵的结论
- 用python祝男朋友生日快乐_祝男朋友生日快乐的说说50句
- 元数据管理器中存在错误
- svn checkout 忽略某个文件夹
- 如何在保持营养均衡的同时不长肉
- python写api接口实战
- 在基于ZYNQ MPSOC XCZU3CG自定义单板上运行DPU例程
热门文章
- python网络验证系统_python3+django2 开发易语言网络验证(下)
- 微信发ascii_微信公众平台开发(107) 分享到朋友圈和发送给好友
- 广东哪所大学计算机专业好,准备考研,广东哪所大学的计算机专业最好?除了985,这所大学性价比很高...
- z变换解差分方程例题_某些常见微分方程的一般解法(工具向)
- 如何复制服务器数据库文件大小,如何复制服务器数据库文件夹
- mysql 备库,【MySQL】数据库备库策略与脚本
- Linux FTP安装问题
- Flask框架 - 初识
- C#调用Java方法(详细实例)
- eclipse和myeclipse的差别问题