06 February, 2017

Spring Boot plugin duplicates dependencies

Recently I found that Spring Boot Maven plugin duplicates some dependencies in the output war file. The problem with time-stamped snapshot dependencies (they have versions like "1.1-20170206.160055-1"). In this case Spring Boot plugin puts both "1.1-SNAPSHOT" and "1.1-20170206.160055-1" versions of jars. Like here:

demo-webapp-1.1-20170206.160055-1.war:\WEB-INF\lib\
                        demo-core-1.1-SNAPSHOT.jar 
                        demo-core-1.1-20170206.160055-1.jar 

This is not critical (application will work), but unpleasant.

The problem occurs with a Spring Boot Maven plugin version before 1.4.4. With 1.4.4 it works fine. So just switch plugin to the 1.4.4, even if you use are using an earlier version of Spring Boot.

<plugins>
    <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <version>1.4.4.RELEASE</version>
    </plugin>
...

After that it will keep only one file per dependency:

demo-webapp-1.1-20170206.160055-1.war:\WEB-INF\lib\
                        demo-core-1.1-SNAPSHOT.jar 

No comments: