Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I prevent Maven's spring-boot plugin from copying static resources to target?

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?

like image 411
anikolis Avatar asked Feb 17 '16 18:02

anikolis


People also ask

What does spring-boot Maven plugin do?

The Spring Boot Maven Plugin provides Spring Boot support in Apache Maven. It allows you to package executable jar or war archives, run Spring Boot applications, generate build information and start your Spring Boot application prior to running integration tests.

What is spring-boot dependency management?

Dependency is nothing but a 'Library' that provides specific functionality that we can use in our application. In Spring-Boot, Dependency Management and Auto-Configuration work simultaneously.

What is the starter that can be used to add spring-boot dependency jars for a spring-boot application?

Spring Boot provides a number of “Starters” that let you add jars to your classpath. Our applications for smoke tests use the spring-boot-starter-parent in the parent section of the POM. The spring-boot-starter-parent is a special starter that provides useful Maven defaults.


1 Answers

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.

like image 149
anikolis Avatar answered Oct 28 '22 14:10

anikolis