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
What helped me in IntelliJ 15.0, windows 10, was the following sequence:
STEP 1: Added the following dependency in pom (This is mentioned everywhere but this alone dint solve it), as mentioned by @jonashackt
STEP 2: Then from File->Settings-> Build-Execution-Deployment -> Compiler (make sure main compiler option is selected and not any of its sub-options)
enable Make Project Automatically. Click ok and close the dialog
STEP 3: Hold Shift+Ctrl+A (on windows) you will see a search dialog with title "Enter Action or option name", type registry. Double click the first option that says "Registry..." it will open another window. Look for the following option:
and enable it, click close
STEP 4: Restart IDE
Elaborated from this source
I recommend Thymeleaf (template engine), jRebel for personal developer. Thymeleaf template files are just HTML resources. So, they`re changed immediately after you edit template files.
In Intellij, I can get this behavior. When the program is running in debug mode, select
Run > Reload Changed Classes
Note: After Intellij completes the action, it might say
Loaded classes are up to date. Nothing to reload
. This is misleading, because it actually DID reload your classpath resources.My environment/setup includes:
Intellij 13
Embedded Tomcat
Run/Debug configuration of type 'Application' (which just uses a main class)
Serving static html, css and js (no jsp)
You can also use JRebel - it will reload all changes (better hotswap) including spring beans. It is easily integratred with both Intellij and Eclipse.
I do not know how far this kind of support goes, but in case you use Eclipse IDE (or anyone reading this): starting up your Spring-Boot application via m2e in debug-mode (press the "Debug"-dropdown button and pick your maven run configuration item).
It works for me like a charm.
My maven run configuration item is configured as follows:
I am not using any further libraries (not even spring-boot-devtools).
That's it.