6

I recently updated the OS on my laptop (Linux Mint 17.1 => 17.3) and now when I run my project with

mvn spring-boot:run

static resources are copied to the target folder, essentially caching them. Thus I have to completely bounce the server to see changes made to the static resources reflected in the browser.

This was not the case before I updated my laptop. I have also found that it is exclusive to this project, other spring-boot projects are not affected.

I also cannot get static resources to update when running in eclipse, both in normal and debug mode.

Some additional information:

Java version: 1.7
Spring-boot version: 1.3.2
spring-boot maven plugin version: 1.3.2
Maven version: 3.3.9

Any ideas?

anikolis
  • 81
  • 5

1 Answers1

2

Explicitly setting the addResources config item in the spring-boot maven plugin seems to fix this. The plugin declaration in your pom file will look like this:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <addResources>true</addResources>
    </configuration>        
    <executions>
        <execution>
            <goals>
                <goal>repackage</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Interestingly, adding the spring-boot-devtools dependency doesn't not fix this, despite the documentation specifically mentioning it would do the same thing as the addResources config item.

Tunaki
  • 132,869
  • 46
  • 340
  • 423
anikolis
  • 81
  • 5
  • This works when running on the command line with `mvn spring-boot:run` but IntelliJ will not pick up changes with this option when using a Spring Boot configuration. Executing `Make Module` will reload the changes but this is not ideal. – andyb Sep 12 '16 at 15:16
  • I use eclipse, but I believe this is possible with IntelliJ as well. You can create a maven run configuration that uses the spring-boot:run goal. This also allows you to use your IDE's debugging tools and keep the benefits of spring-boot:run.. – anikolis Sep 13 '16 at 17:54
  • Yes, I used this approach too. There is a better solution given [here](http://stackoverflow.com/a/35895848/637889) which makes IntelliJ auto-reload the resources – andyb Sep 14 '16 at 08:53