SpringBoot项目在IntelliJ IDEA中实现热部署
来源:互联网 发布:程序员的鄙视链 庞博 编辑:程序博客网 时间:2024/05/23 19:03
Spring Boot 实现热部署很简单,我们使用上一章创建的项目 Springboot 创建简单的 web 交互应用 来演示。
1、使用 Spring Loaded
2、使用 spring-boot-devtools
springloaded
在 POM 文件中添加依赖
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>springloaded</artifactId> <version>1.2.6.RELEASE</version> </dependency> </dependencies> </plugin> </plugins></build>
添加完毕,启动项目
原理是在发现代码有更改之后,重新启动应用,但是速度比手动停止后再启动更快。
其深层原理是使用了两个ClassLoader,一个Classloader加载那些不会改变的类(第三方Jar包),另一个ClassLoader加载会更改的类,称为restart ClassLoader
,这样在有代码更改的时候,原来的restart ClassLoader被丢弃,重新创建一个restart ClassLoader,由于需要加载的类相比较少,所以实现了较快的重启时间。
spring-boot-devtools
添加 POM 文件依赖
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency>
即devtools会监听classpath下的文件变动,并且会立即重启应用(发生在保存时机)
另外需要开启idea自动编译功能
一、开启idea自动make功能 1、CTRL + SHIFT + A --> 查找make project automatically --> 选中 Make project automatically (mac使用 command+shift+a)2、CTRL + SHIFT + A --> 查找Registry --> 找到并勾选compiler.automake.allow.when.app.running
页面热部署
devtools可以实现页面热部署,即页面修改后会立即生效。你可以在application.properties文件中配置spring.thymeleaf.cache=false来实现这个功能。
#禁止thymeleaf缓存(建议:开发环境设置为false,生成环境设置为true)spring.thymeleaf.cache=false
另外启动项目需要使用maven命令启动
mvn spring-boot:run
至此全部完结。
阅读全文
0 0
- SpringBoot项目在IntelliJ IDEA中实现热部署
- SpringBoot项目在IntelliJ IDEA中实现热部署
- SpringBoot项目在IntelliJ IDEA中实现热部署
- SpringBoot项目在IntelliJ IDEA中实现热部署
- SpringBoot项目在intellij idea中实现热部署
- SpringBoot项目在IntelliJ IDEA中实现热部署
- SpringBoot项目在IntelliJ IDEA中实现热部署
- SpringBoot项目在IntelliJ IDEA中实现热部署
- SpringBoot项目在IntelliJ IDEA中实现热部署
- SpringBoot项目在IntelliJ IDEA中实现热部署
- IntelliJ IDEA中实现SpringBoot热部署
- springboot 在idea中实现热部署
- Intellij IDEA SpringBoot项目热部署解决方案
- 关于SpringBoot在idea中实现热部署
- idea中springboot实现热部署
- Springboot idea中实现热部署
- Intellij IDEA中实现热部署
- Intellij IDEA中实现热部署
- input 样式
- IntelliJ Idea 常用快捷键列表
- 文件复制
- Android studio 编译错误
- Linux中mariadb数据库的安装与配置
- SpringBoot项目在IntelliJ IDEA中实现热部署
- git 常用命令
- Javascript Dom编程艺术读书笔记(三)
- 项目开发总结之通用适配器
- 错过
- coding
- 本地CentOS 7 下 安装 LEMP 服务(nginx+MariaDB+php)
- PHP基于标准的CBC模式的DES加密算法
- UltraEdit查看class的jdk版本