Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 789 Vote(s) - 3.54 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Spring boot devtools - Static content reloading does not work in IntelliJ

#1
When building my first Spring Boot app, I discovered that I need to restart my app every time I make a change to a Javascript file in /resources/static/some-file.js

This is very time consuming.

When I move the files to the /webapps/ folder, it works as expected, but the files are not packaged in a JAR. The docs mention this, so I cannot continue this way.

I read all about `spring-boot-devtools`, and have installed it in my POM, but the hotswapping doesn't seam to be working. I still need to restart the entire app to see a Javascript or CSS file change.

When the app starts, I can see the line `LiveReload server is running on port 35729`, so `spring-boot-devtools` must be doing something...

What would be the steps to further investigate what is going wrong?

My guess is that when IntelliJ runs the app, the files are copied, so when I make a change, I'm actually changing the original files and not the ones used by the running app.

PS: I'm using Maven, IntelliJ IDEA 15 and Spring Boot 1.3.3 with the embedded Tomcat server. I'm not sure what command IntelliJ runs to start the app. The IDE is handling this "automatically". Perhaps I need to change my run configuration?
Reply

#2
For Windows users the steps are:
1) Go to File->Settings, then to "Build,Execution,Deployment"->Compiler and enable the "Make project automatically" flag.
2) Press Ctrl-Alt-Shift-/ and select "Registry" from the menu that appears. Enable compiler.automake.allow.when.app.running flag.
3) Start/restart the app and observe static content reloading.
Reply

#3
For mac users I had to press <kbd>Command</kbd> + <kbd>Shift</kbd> + <kbd>A</kbd>

And restart INTELLIJ after Step1 and Step2 without which the registry option was not appearing.
Reply

#4
On Linux, press:

<kbd>Ctrl</kbd>-<kbd>Alt</kbd>-<kbd>Shift</kbd>-<kbd>/</kbd>
Reply

#5
You need to turn on a couple of features in IntelliJ to make this work.

First, there's a project specific setting which you would need to apply on any project you want to use devtools in. Go to Preferences > Compiler and enable "Make project automatically."

The next setting is an IDEA registry setting that applies to all projects.

* In macOS (OSX), press `Shift+Command+A` (`Shift+Ctrl+A` in Windows)
* Type "Registry" in the search box that appears, and select the registry to open it.
* Lookup **compiler.automake.allow.when.app.running** and enable it.

After that, restart your app. You will notice that the project keeps rebuilding with every change you make. When you check out the result in the browser, you will see both static files and code have been updated.
Reply

#6
You can user like bellow:

1. **First** Open Preferences.../Settings... -> Build, Execution, Deployment -> Compiler and allow Build project automatically. Image will look like

[![enter image description here][1]][1]


2. **Second**, we change Registry configuration. Press **command+shift+A** for **macOS** or if you are using **Windows** press **Ctrl+Shift+A**, and search for Registry. **enable compiler.automake.allow.when.app.running**.Images look like bellow

**Registry image look like..**

[![enter image description here][2]][2]


**compiler.automake.allow.when.app.running enable image look like**
[![enter image description here][3]][3]

Then Enjoy..

[1]:

[2]:

[3]:
Reply

#7
For **IntelliJ 2021.2 version or above** below are steps that you need to follow

1. Add **spring-boot-devtools** dependency if not already added.

2. Enable **Build project automatically** as shown below

[![enter image description here][1]][1]


3. Enable option in **Advanced Settings** as shown below

[![enter image description here][2]][2]


[1]:

[2]:
Reply

#8
**The option is now in Advanced settings:**

[![IntelliJ Advanced Setting][1]][1]


[1]:

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through