admin管理员组

文章数量:1641327

The bean 'requestMappingHandlerAdapter', defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/web/reactive/config/DelegatingWebFluxConfiguration.class] and overriding is disabled.

由于我的common的模块引入了

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

网关中的 spring-boot-starter-webflux 包含了spring-web 的依赖,所以

目前我在资源服务器中使用了 SecurityWebFilterChain (spring-web下的一个配置类)类,建议在引入common模块(或其他包含spring-web、spring-boot-starter-web模块)排除掉,如下:

        <dependency>
            <groupId>com.zmc</groupId>
            <artifactId>common</artifactId>
            <version>1.0-SNAPSHOT</version>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-web</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

排除后,common模块又开始报错了,因为我在common模块中引入了servlet相关的东西,如:
javax.servlet.ServletRequest
但在网关中引入是排除了spring-boot-start-web , 可以引入这一块相关的jar依赖解决(其实可以直接删除spring-start-web依赖,只要引用的东西不多,可以引入细粒度的jar就行)

  <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
        </dependency>

本文标签: WebFluxSecurityConfigurationGatewayclassdisabledoverriding