网关异常报Consider defining a bean of type 'org.springframework.http.codec.ServerCodec,
要排除其他依赖的spring-boot-starter-web,因为会与spring cloud gateway的webflux冲突。

        <!-- 核心模块,因为我的核心模块引入了spring-boot-starter-web,将其排除  -->
        <dependency>
            <groupId>huluwa</groupId>
            <artifactId>boss-xtrain-core</artifactId>
            <version>${huluwa.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-web</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        
        <!--新增gateway,要排除其他依赖的spring-boot-starter-web,因为会与gateway的webflux冲突
        不排除依赖报Consider defining a bean of type 'org.springframework.http.codec.ServerCodecConfigurer' in your configuration.-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-gateway</artifactId>
        </dependency>

至此,成功解决~

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐