Trouble when changing Spring Boot version from 2.0.3.RELEASE to 2.1.0.BUILD-SNAPSHOT

So as the exception reports, there are two beans of the same type. Historically Spring would override one bean with the other. That has long been an annoyance since you could get hard to find bugs where a second bean with a completely different type, but with the same bean ID would make your first bean vanish.

Spring Boot 2 now disables that sort of bean overriding by default. You can re-enable it by setting the following property in your application.yml:

spring.main.allow-bean-definition-overriding: true

This re-enables the previous behavior. It doesn’t address the root cause that beans are being overridden though and also mean you won’t get the benefit of bean override errors. Upgrading the underlying libraries will hopefully clean this up over time.

As noted on other comments, upgrading the spring-security-oauth2-autoconfigure dependency to may solve it for you.

Leave a Comment