5

I'm using Spring Boot 2.0.4.RELEASE with embedded Tomcat server and Intellij Idea 2018.2 on my Os X High Sierra.

As tutorial says

https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-devtools.html

I added in my pom.xml following dependency

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <optional>true</optional>
    </dependency>
</dependencies>

And after that I see

[ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729

wher server starts.

But anyway changes in static sources has no effect, and I have to press Cmd+F9 to see that in the browser.

I tried all tips from IntelliJ 15, SpringBoot devtools livereload not working

like turning on 'Build project programmatically' or 'compiler.automake.allow.when.app.running', but nothing helps.

My static sources (angularjs templates an files) living at

src > main > resources > static > templates

may be location for static is wrong?

Any ideas appreciated!

Arkady
  • 1,178
  • 14
  • 35
  • Have you made sure you're doing a purge/reload for your browser cache? – Dovmo Aug 12 '18 at 21:44
  • @Dovmo what do you mean? – Arkady Aug 13 '18 at 08:37
  • When you open Chrome `DevTools` you can click and hold the browser refresh button and click `Empty Cache and Hard Reload`. You can also select the option in DevTools for [`Disable Cache`](https://www.technipages.com/google-chrome-how-to-completely-disable-cache) to turn it off. It will force-reload those static resources when you revisit the page – Dovmo Aug 13 '18 at 13:54
  • @Dovmo exact reason why I want to use live reload is not to use 'clean cache' :) I also use Playframework on another project, and there live reload works smooth as baby bottom, without cleaning cache in browser. But not with Spring :/ – Arkady Aug 15 '18 at 16:28
  • Arkady, sure that's fair, but reporting on whether doing a hard-refresh / Disable Cache on your browser resolves the issue could be helpful in debugging the root cause of the issue – Ben M Aug 15 '18 at 18:17
  • When the 'devtools' dependency is present, LiveReaload is automatically enabled. In case, it is disabled in any of the configuration properties files, you can enable it adding the line `spring.devtools.livereload.enabled=true` – Johna Aug 17 '18 at 02:57
  • @Johna I've tried to add this option. Unfortunately, it has no effect.. – Arkady Aug 17 '18 at 12:25

2 Answers2

0

Put the static at the same level as src as a "resources" folder.

0

I think that there is a misunderstanding here.

Among other things, the spring dev-tools offer you Automatic Restart (which is going to restart the server completely when there is a change in the classpath, excluding the static resources) and Live Reload (reload the browser when there is a change in the static resources).

With that being said, the Live Reload feature has two details that you need to keep in mind:

  1. You also need to install and use a browser extension like: https://chrome.google.com/webstore/detail/livereload/jnihajbhpnppcggbcgedagnkighmdlei
  2. You can only have one server with live reload at the time (Otherwise, only the first one will be used).

With this configuration, a change in a static file should trigger the browser reload. If the change in the file is not enough, try building the project without stop it.

In Eclipse, saving a modified file causes the classpath to be updated and triggers a restart. In IntelliJ IDEA, building the project (Build -> Build Project) has the same effect.

Ariel Kohan
  • 674
  • 4
  • 15