本文介绍了春天靴子热插拔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用Spring Boot做了P.O.C。



到目前为止,这是非常好的,有前途的,但有一个主要的缺点:我正在使用嵌入式服务器(即将网络应用程序打包在一个 .jar ),所以在开发时,我必须重建jar并重新启动服务器,每次我更改CSS,HTML或JS文件。没有热插拔。这真的减慢了UI开发。



我可以想到几个快速修复,例如从另一个域加载静态资源,并从本地的 nginx ,还有一些这样的变体,但是在使用IntelliJ / Eclipse时,是不是有一些内置的选项?

解决方案

有几个选项。在IDE中运行(特别是调试)是一个很好的开发方法(所有现代IDE都允许重新加载静态资源,通常也是Java类更改的热切)。 Spring Boot devtools是一个很便宜的方式来获得相当大的提升(只需将其添加到您的类路径中)。当检测到更改时,可以在热JVM中重新启动应用程序。它也在运行时关闭诸如百里香缓存之类的东西,因此您不必自己记住这样做。如果您使用更高级别的工具编写该代码,则可以使用外部css / js编译器进程。



不再推荐,但可能仍在使用中。如果您需要零延迟的热交换(例如JRebel),更复杂的基于代理的工具可以更好地工作。



请参阅

I've been doing a P.O.C with Spring Boot.

So far it's been going really good and promising, but there's one major drawback: I'm using an embedded server (i.e., packaging the web app in a .jar), so when developing I have to rebuild the jar and restart the server every time I change the CSS, HTML or JS files. There's not hot-swap. This really slows down the UI development.

I can think of several quick fixes, such as loading static resources off a different domain and serving it from a local nginx, and some more variations like this, but isn't there a built-in option of some sort when working with IntelliJ/Eclipse?

There are several options. Running in an IDE (especially with debugging on) is a good way to do development (all modern IDEs allow reloading of static resources and usually also hotswapping of Java class changes). Spring Boot devtools is a cheap way to get quite a big boost (just add it to your classpath). It works by restarting your application in a hot JVM when changes are detected. It also switches off things like thymeleaf caches while it is running, so you don't have to remember to do that yourself. You can use it with an external css/js compiler process if you are writing that code with higher level tools.

Spring Loaded is no longer recommended, but probably still in use. More sophisticated agent-based tools work much better if you need hot swapping with zero delay (e.g. JRebel).

See the docs for some up to date content

这篇关于春天靴子热插拔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 22:19