SpringBoot - 如何使用spring-boot-devtools实现自动编译重启?

避坑指南:WSL2网络模式修改导致无法上网的解决方案(附备份还原技巧) 本文深入解析WSL2默认网络隔离机制,并提供三种安全的端口互通方案,重点推荐通过配置Windows防火墙规则实现稳定访问。同时,针对网络配置修改可能引发的无法上网问题,给出了从重置配置到系统级备份的完整恢复指南,确保开发环境安全可靠。 阅读详情
写在前面

在基于SpringBoot框架的项目中,每次修改代码之后手动重启项目这样十分浪费时间,Spring为开发者提供了spring-boot-devtools 模块使得 SpringBoot 的应用支持热部署,当配置了 devtools 后,我们在 classpath中 修改任何文件后项目都将会自动编译并重启。

如何使用

1. 添加依赖
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <!-- 为了防止将devtools依赖传递到其它模块中,当开发者将应用打包运行后,devtools会被自动禁用. -->
    <optional>true</optional> <!-- 表示依赖不会传递 -->
</dependency>
2. 增加配置
# Spring配置
spring:
  profiles:
    active: dev
  # 文件上传
  servlet:
     multipart:
       # 单个文件大小
       max-file-size:  10MB
       # 设置总上传的文件大小
       max-request-size:  20MB
  # 服务模块
  devtools:
    restart:
      # 热部署开关
      enabled: true
      # 设置需要重启的目录
      additional-paths: src/main/*
      # 设置不需要重启的目录
      exclude: static/**,public/**
    # 是否支持livereload
    livereload:
      enabled: true
4. 设置IDEA

在这里插入图片描述
请添加图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

5. 重启项目
6. 每次修改完毕以后按下快捷键:ctrl+f9

源码、示例及DEMO

源码、示例及DEMO

那些年对支付宝的研究[整理] 支付宝功能强大.他内部各个功能间的跳转是通过Uri 实现的.而使用window.location.href 即可.跟浏览器一样的协议.很方便 H5启动支付宝: alipays://platformapi/startapp?appId=20000067&url=网址 alipays://platformapi/startapp?appId=20000691&url=网址 ali... 阅读详情

相关推荐

Reeds-Shepp曲线公式推导及代码实现-第二部分(共三部分)

文章目录2. Reeds-Shepp求解2.1 L+S+L+L^+S^+L^+L+S+L+2.2 L+S+R+L^+S^+R^+L+S+R+2.3 L+R−L+L^+R^-L^+L+R−L+2.4 L+R−L−L^+R^-L^-L+R−L−2.5 L+R+L−L^+R^+L^-L+R+L−2.6 L+Rβ+Lβ−R−L^+R_{\beta}^+L_{\beta}^-R^-L+Rβ+​Lβ−​R−2.7 L+Rβ−Lβ−R+L^+R_{\beta}^-L_{\beta}^-R^+L+Rβ−​Lβ−​R+2.8

jianmo的博客 1217

SpringBoot热部署环境配置与测试

什么是热部署? 热部署,就是我们在项目正在运行的时候进行了项目改造升级(增加业务),却不需要重新启动项目。 大家都知道在项目开发过程中,常常会改动页面数据或者修改数据结构,为了显示改动效果,往往需 要重启应用查看改变效果,其实就是重新编译生成了新的Class文件,这个文件里记录着和代码等对应 的各种信息,然后Class文件将被虚拟机的ClassLoader加载。 而热部署正是利用了这个特点,它监听到如果有 Class 文件改动了,就会创建一个新的ClaassLoader 进行加载该文件...

haiertadiedie的博客 1182

玉米群体遗传分析实战:如何用IQtree和VCF文件快速构建系统发育树(附避坑指南)

本文详细介绍了如何利用IQtree和VCF文件进行玉米群体遗传分析,并快速构建可靠的系统发育树。文章重点解析了从VCF格式转换到PHYLIP格式的实用技巧,强调了使用ASC模型校正SNP数据偏差的重要性,并提供了完整的参数设置、常见报错解决方案及结果评估指南,帮助研究者高效完成分析并规避常见陷阱。

leaf8的博客 616

Springboot学习:DevTools与热部署

Pom.xml修改 <!--热部署相关,devtools--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <!--当这个项目被继承时,这个不向下传递-->

Soraa的博客 351

告别理论!用AXI-Stream实战摄像头数据流采集(附Verilog关键代码片段)

本文详细解析了如何通过AXI-Stream接口实现工业级可靠性的摄像头数据流采集系统,重点介绍了Verilog实战代码、AXI-Stream握手机制及数据反压处理方案。通过三级缓冲架构和带宽优化,有效解决了OV5640等摄像头在高速场景下的帧丢失问题,为FPGA图像处理项目提供了实用解决方案。

weixin_42563415的博客 159

opencv图像去畸变

opencv图像去畸变

智能机器人产学研基地 4883

Spring boot 项目热部署

添加热部署工具devtools,在pom.xml中添加以下依赖 <!--热部署,使用次工具,修改文件之后不用手动重新启动服务--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</ar...

weixin_43142423的博客 411

手把手教你用STM32驱动SPL06-001气压传感器(附完整代码与避坑指南)

本文详细介绍了如何使用STM32驱动SPL06-001气压传感器,包括硬件连接、寄存器配置、驱动层实现和数据补偿算法。通过完整的代码示例和避坑指南,帮助开发者快速掌握SPL06传感器的应用技巧,提升嵌入式系统开发效率。

weixin_42552315的博客 296

SpringBoot入门 - 配置热部署devtools工具

热部署和热加载是在应用正在运行的时候,自动更新(重新加载或者替换class等)应用的一种能力。(PS:spring-boot-devtools提供的方案也是要重启的,只是无需手动重启能实现自动加载而已。严格意义上,我们需要区分下热部署和热加载, 对于Java项目而言:热部署在服务器运行时重新部署项目它是直接重新加载整个应用,这种方式会释放内存,比热加载更加干净彻底,但同时也更费时间。热加载在运行时重新加载class,从而升级应用。热加载的实现原理主要依赖java的类加载机制。

DeveloperFire的博客 4458

游戏开发实战:如何用旋转矩阵实现2D角色平滑转向(附Unity代码)

本文深入探讨了在Unity游戏开发中,如何运用旋转矩阵原理实现2D角色的平滑转向。文章从核心理论出发,提供了计算目标旋转、实现平滑插值(Lerp与SmoothDamp)的完整C#代码,并解决了与动画系统、物理引擎协同的常见难题,帮助开发者提升游戏操作手感与视觉流畅度。

weixin_29057237的博客 302

IDEA中SpringBoot项目如何实现maven自动编译以及服务热部署

启动SpringBoot项目,修改服务代码。首先查看target目录下代码与修改后的代码是否一致。然后通过服务运行效果确认代码是否已部署。devtools热部署,会在控制台打印日志。可观察修改是否已完成部署。2)勾选高级设置里的应用运行中允许自动编译。1)打开IDEA的设置,勾选自动编译。自动编译较慢,可能得稍候才能编译完成。

weixin_43827572的博客 2734

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain&#39;s apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath(&#39;DeepLearnToolbox&#39;));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand(&#39;state&#39;,0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = &#39;sigm&#39;;%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, &#39;Too big error&#39;);```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, &#39;Too big error&#39;);```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

idea项目自动重启_Intellij - 实现项目的热部署1(使用spring-boot-devtools实现自动编译重启)...

在开发 Spring Boot项目时,每次修改代码之后都需要手动重启项目,十分浪费时间。Spring 为开发者提供了一个名为spring-boot-devtools的模块来使 Spring Boot应用支持热部署,当配置了 devtools 后,我们在 classpath 修改任何文件后项目都将会自动编译并重启。1,添加依赖(1)首先我们修改项目的 pom.xml文件,在 dependencies...

weixin_39817122的博客 909

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

SpringBoot:模块探究之spring-boot-devtools

Spring Boot 使我们能够快速设置和运行服务。为了进一步增强开发体验,Spring 发布了 spring-boot-devtools 工具——作为 Spring Boot-1.3 的一部分 spring-boot-devtools 是 Spring Boot 提供的一组开发工具,可以提高开发者的工作效率,开发者可以将该模块包含在任何项目中,spring-boot-devtools 最方便的地方莫过于热部署了。

栗筝i的博客 5567

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

SpringBoot - 如何使用spring-boot-devtools实现自动编译重启

原文链接:https://blog.csdn.net/goodjava2007/article/details/127053250。

a863922230的专栏 214

SpringBoot开发模式自动重启热部署spring-boot-devtools

1、添加依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency> 2、修改配置application.yml spring: devtools:

彭世瑜的博客 2502

SpringBoot热部署-spring-boot-devtools

SpringBoot热部署 热部署不会用在生产环境,但对于程序员开发的效率,还是有一定帮助的,所谓的热部署,就是在应用程序在不停止的情况下,实现新的部署 spring-boot-devtools 是一个为开发者服务的一个模块,其中最重要的功能就是自动应用代码更改到最新的App上面去。原理是在发现代码有更改之后,重新启动应用,但是速度比手动停止后再启动还要更快,更快指的不是节省出来的手工操作的时间。 其深层原理是使用了两个ClassLoader,一个Classloader加载那些不会改变的类(第三方Jar包)

努力学习 2702

IDEA实现springboot热更新(spring-boot-devtools)

IDEA实现springboot热更新(spring-boot-devtools)

Dai的博客 2502

SpringBoot热部署实战:IDEA配置与DevTools原理详解

热部署是提升Java开发效率的核心技术之一,它允许开发者在修改代码后无需重启应用即可立即生效,从而保持开发思维的连续性。其原理主要分为字节码增强和快速重启两种,前者通过JVM代理动态替换类定义,后者则通过双类加载器机制实现轻量级应用上下文重建。在SpringBoot生态中,spring-boot-devtools作为官方推荐方案,通过监控classpath变化触发快速重启,大幅缩短了反馈周期。这项技术对于微服务架构下的快速迭代和持续集成场景尤为重要,能有效减少开发等待时间。本文将结合IDEA的自动编译机制,

weixin_29895109的博客 315

SpringBoot实现热部署,修改代码不用重启服务

我们在开发中反复修改类、页面等资源,每次修改后都是需要重新启动才生效,这样每次启动都很麻烦,浪费了大量的时间。 能不能在我修改代码后不重启就能生效呢?可以,由于Spring Boot应用只是普通的Java应用,所以JVM热交换(hot-swapping)也能开箱即用。不过JVM热交换能替换的字节码有限制,想要更彻底的解决方案可以使用Spring Loaded项目或JRebel。 spring-boot-devtools 模块也支持应用快速重启(restart),即实现“热部署”。 1. 在pom.

qq_42165679的博客 5965

解决IDEA下Spring boot项目修改html,js数据还要重启的问题,亲测有效

目录 测试一: 方法一: 测试代码: test.html testcontroller 测试效果 测试二: 方法二: 测试效果 总结:推荐使用方法二 刚转来用IDEA没多久,写项目时遇到修改html和js的数据还要重启才能更新。what?还能被这个难住? 百度了很多,基本上无非就是改2种设置,那么到底改哪些才是有用的呢?当然可以一股脑全改了,但是总不能一直不求甚解吧。 测...

chen_cm的博客 4952

Spring Boot 热部署

Spring 热部署, 解放程序员双手重启代码

这个人很懒, 什么都没留下(这是我写的) 1825

[实用]Spring Boot の 热部署/热更新

SpringBoot 热部署 热更新

筱原空的世界 6314

Intellij IDEA 使用Spring-boot-devTools无效解决办法

SpringBoot还要有一个额外的部署工具集,让热部署体验更加舒服,减少调试时间,在这个过程中需要的插件是:dependencies> dependency> groupId>org.springframework.bootgroupId> artifactId>spring-boot-devtoolsartifactId> optiona

betty_bao的博客 2396

spring boot热部署的好处

** 卑微小白初次尝试SpringBoot热部署 ** 1、什么是SpringBoot热部署 通俗的说,就是当你在修改SpringBoot项目中的静态资源的时候,不需要每一次都要去重启项目才能达到预期效果,(今天楼主被项目经理要求改一些静态资源,一次次的重启SpringBoot,实在受不了,故写下这篇博客,希望可以帮助到大家)。 2、怎么使用SpringBoot热部署 首先在你pom.xml文件中...

weixin_40471400的博客 2221

spring boot 热部署

频繁地重启应用,导致开发效率降低,加班随之而来。有没有什么办法,能让 Spring Boot 项目热部署呢,从而不用每次都手点。。

wlm123565的博客 1053
上一篇: SpringBoot - 如何解决多模块依赖时BEAN无法注入的问题?
下一篇: JAVA基础 - Integer之间的比较
cloneme01
博客等级 码龄20年 2万+粉丝 248原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

cloneme01

谢谢您的支持与鼓励!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址