SpringBootforIDEA热部署开发配置详解
目录
- 更多分享:www.catbro.cn
- windows 、Mac中Spring boot 热部署、热加载配置详解
Developer Tools 开发工具
-
官方说明:
-
Spring Boot includes an additional set of tools that can make the application development experience a little more pleasant. The spring-boot-devtools module can be included in any project to provide additional development-time features. To include devtools support, add the module dependency to your build, as shown in the following listings for Maven and Gradle:
-
大概意思:Spring Boot 包含一组额外的工具集合,通过使用该工具集合可以有效提高使应用程序的开发体验。spring-boot-devtools模块可以在任何项目中使用去提供额外的开发运行时特性。要包含devtools支持,请将模块依赖项添加到您的构建中,如以下Maven和Gradle列表所示:
-
Maven.
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency> </dependencies>
-
Gradle.
configurations { developmentOnly runtimeClasspath { extendsFrom developmentOnly } } dependencies { developmentOnly("org.springframework.boot:spring-boot-devtools") }
Automatic Restart 自动重启
- Applications that use spring-boot-devtools automatically restart whenever files on the classpath change. This can be a useful feature when working in an IDE, as it gives a very fast feedback loop for code changes. By default, any entry on the classpath that points to a folder is monitored for changes. Note that certain resources, such as static assets and view templates, do not need to restart the application.
- 使用spring-boot-devtools的应用程序会在类路径上的文件发生更改时自动重新启动。 在IDE中工作时,这可能是一个有用的功能,因为它为代码更改提供了非常快速的反馈循环。 默认情况下,将监视类路径上指向文件夹的任何条目的更改。 请注意,某些资源(如静态资产和视图模板)无需重新启动应用程序。
Spring Boot + Idea
- 在使用idea开发时你会发现热重启并未生效
- 我们再对idea做如下配置即可
- 1、开启工程自动编译功能,如下:选择File -》 Settings -》Compiler,然后将Build project automatically 选中,点击apply(右下角)
- 2、windows快捷键ctrl+alt+shift / mac快捷键 option+command+shift /
- 然后点击Registry,勾选红色箭头的选项,重启项目即可
- 亲测有效哦亲