graphql-java-kickstart / graphql-spring-boot

GraphQL and GraphiQL Spring Framework Boot Starters - Forked from oembedler/graphql-spring-boot due to inactivity.
https://www.graphql-java-kickstart.com/spring-boot/
MIT License
1.5k stars 325 forks source link

SpringDoc bean name conflict error #909

Closed miriyalajanardhan closed 1 year ago

miriyalajanardhan commented 1 year ago

I tried to upgrade to spring boot 3.0.0

<dependency>
        <groupId>org.springdoc</groupId>
        <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
        <version>2.0.2</version>
    </dependency>
    <dependency>
        <groupId>com.graphql-java-kickstart</groupId>
        <artifactId>graphql-spring-boot-starter</artifactId>
        <version>15.0.0</version>
    </dependency>

The problem is they both have a Bean with the name 'objectMapperProvider'.

Description:

The bean 'objectMapperProvider', defined in class path resource [org/springdoc/core/configuration/SpringDocConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [graphql/kickstart/autoconfigure/web/servlet/GraphQLWebAutoConfiguration.class] and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true

oliemansm commented 1 year ago

This is not a bug of this project. This is simply a naming conflict. This library has marked the creation of the ObjectMapperProvider as @ConditionalOnMissingBean. Sounds like that springdoc library does not use such an annotation and therefore the conflict occurs. So you should check with the springdoc library if it's possible to add that @ConditionalOnMissingBean annotation there too, since they're the one actually causing this error. In the meantime you can execute the action they suggest by allowing bean definition overriding.