Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
326 views
in Technique[技术] by (71.8m points)

java - Hot swapping in Spring Boot

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...