When upgrading to Spring Boot 2.2.6.RELEASE, the spring-boot-starter-security
jar brings in org.springframework:spring-web:jar:5.2.3.RELEASE
.
In turn, the org.springframework.boot:spring-boot-starter-web:jar:2.2.6.RELEASE
brings in org.springframework:spring-webmvc:jar:5.2.5.RELEASE
.
These two transient libraries are incompatible. See logs below:
APPLICATION FAILED TO START
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.springframework.web.servlet.resource.ResourceHttpRequestHandler.afterPropertiesSet(ResourceHttpRequestHandler.java:378)
The following method did not exist:
org.springframework.web.accept.ContentNegotiationManager.getMediaTypeMappings()Ljava/util/Map;
The method's class, org.springframework.web.accept.ContentNegotiationManager, is available from the following locations:
jar:file:/Users/marco/.m2/repository/org/springframework/spring-web/5.2.3.RELEASE/spring-web-5.2.3.RELEASE.jar!/org/springframework/web/accept/ContentNegotiationManager.class
It was loaded from the following location:
file:/Users/marco/.m2/repository/org/springframework/spring-web/5.2.3.RELEASE/spring-web-5.2.3.RELEASE.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.springframework.web.accept.ContentNegotiationManager
This issue is fixed when adding the following to the project's dependencyManagement section:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.2.5.RELEASE</version>
</dependency>
Comment From: snicoll
@robertoafjr it shouldn't do that if you're using proper dependency management for your project. Doing so is documented and varies from the build system that you are using. This can also happen when you are overriding versions rather than letting dependency management provide consistent versions for you.
If you have more questions about this topic, please follow-up on StackOverflow, as mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements.