2、Spring-boot热部署
来源:互联网 发布:淘宝发货人信息怎么改 编辑:程序博客网 时间:2024/06/08 15:45
什么是热部署:
简单来说,就是你修改了代码后,不需要重新启动项目就可以在浏览器上直接显示你修改后的效果。
·第一种方法(在spring-boot:run时才有效)
我在实验的时候,在修改返回值,添加新方法,添加新类同时添加新方法, 都可以实时返回新值。
但是在添加一个新的controller的时候是不成功的
<plugin><!-- 热部署插件 --> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin </artifactId> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>springloaded</artifactId> <version>1.2.4.RELEASE</version> </dependency> </dependencies> <executions> <!--后面这些不要也行,我也不知道干什么的--> <execution> <goals> <goal>repackage</goal> </goals> <configuration> <classifier>exec</classifier> </configuration> </execution> </executions> </plugin>
·第二种方法
在pom.xml中添加
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> <!-- optional=true,依赖不会传递,该项目依赖devtools;之后依赖myboot项目的项目如果想要使用devtools,需要重新引入 --> </dependency>
在pom.xml中添加
<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <!-- "如果没有该项配置,devtools不会起作用,即应用不会restart",有人这么说,有人说不弄也行,我没有试过,加上不就得了,没必要瞎折腾 --> <fork>true</fork> </configuration></plugin>
异常处理:
如果不能使用的话,以下就是几种常见的解决方法:
1、看对应的spring-boot-starter-parent版本是否正确。我在运行的时候就抛出App.main异常,更换依赖管理的版本后就好了。换一个更高版本的。
2、是否加入spring-boot-maven-plugin以及属性true
3、Eclipse Project 是否开启了Build Automatically(开启自动编译的功能)。
4、如果设置SpringApplication.setRegisterShutdownHook(false),则自动重启将不起作用。(这个我没试过,百度上是这么说的)
最后,这两种方式springloader、devtools只需要配置一种即可,建议使用devtools,可以支持更多的代码热部署
阅读全文
0 0
- 2、Spring-boot热部署
- spring boot 热部署
- Spring Boot热部署
- spring boot 热部署
- spring boot热部署
- spring boot热部署
- Spring BOOT 热部署
- spring boot热部署
- Spring Boot 热部署
- spring boot热部署
- Spring Boot 热部署
- Spring Boot热部署
- Spring Boot-------热部署
- spring boot 热部署
- Spring-boot 热部署
- Spring Boot热部署spring-boot-devtools
- Spring boot --------(1)热部署
- spring boot 调试 - 热部署
- 白话Lucene原理
- 中文分词综述
- L2-020. 功夫传人
- Angular学习(一)
- null 和 undefined 的区别
- 2、Spring-boot热部署
- elsaticsearch的安装
- Android studio Rendring Problems
- 二、Animation动画插值器
- week12-leetcode #347-Top-K-Frequent-Elements
- 如何编译安装Bundler
- java中equals和==的区别
- java synchronized关键字的用法
- 认知