spring-boot - GatewayAutoConfiguration 需要一个无法找到的 org.springframework.http.codec.ServerCodecConfigurer 类型的 bean
问题描述
我想在我创建的所有服务之间建立通信。当我在我的项目中添加云配置服务器 gradle 依赖项并运行项目时,我遇到了此类问题
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of method modifyRequestBodyGatewayFilterFactory in org.springframework.cloud.gateway.config.GatewayAutoConfiguration required a bean of type 'org.springframework.http.codec.ServerCodecConfigurer' that could not be found.
Action:
Consider defining a bean of type 'org.springframework.http.codec.ServerCodecConfigurer' in your configuration.
Process finished with exit code 1
我已经根据我的知识正确定义了所有内容,但是我无法从过去 2 天中找到问题。我自己尝试这些是我在这个项目 build.gradle.kts 中创建的文件
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.springframework.boot") version "2.4.5"
id("io.spring.dependency-management") version "1.0.11.RELEASE"
kotlin("jvm") version "1.4.32"
kotlin("plugin.spring") version "1.4.32"
}
group = "com.main"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_11
repositories {
mavenCentral()
}
extra["springCloudVersion"] = "2020.0.2"
dependencies {
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.springframework.cloud:spring-cloud-config-server")
implementation("org.springframework.cloud:spring-cloud-starter-gateway")
implementation("org.springframework.cloud:spring-cloud-starter-netflix-eureka-client")
testImplementation("org.springframework.boot:spring-boot-starter-test")
}
dependencyManagement {
imports {
mavenBom("org.springframework.cloud:spring-cloud-dependencies:${property("springCloudVersion")}")
}
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "11"
}
}
tasks.withType<Test> {
useJUnitPlatform()
}
ApiGatewayApplication.kt
package com.main.apigateway
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.cloud.netflix.eureka.EnableEurekaClient
@SpringBootApplication
@EnableEurekaClient
class ApigatewayApplication
fun main(args: Array<String>) {
runApplication<ApigatewayApplication>(*args)
}
应用程序.yml
server:
port: 8999
spring:
application:
name: api-gateway
cloud:
gateway:
routes:
- id: DEPARTMENT-SERVICE
uri: lb://DEPARTMENT-SERVICE
predicates:
- Path=/departments/**
- id: USER-REGISTRATION
uri: lb://USER-REGISTRATION
predicates:
- Path=/users/**
引导程序.yml
spring:
cloud:
config:
enabled: true
uri: http://localhost:9296
解决方案
推荐阅读
- wpf - 与 ObservableCollection 绑定的组合框未更新
- sap-cloud-sdk - 将 FluentHelperRead/Count 与过滤器一起使用时,是否有任何方法可以跳过 Odata 元数据验证?
- mysql - SQL Customer 和 Transaction 中有 2 个表,显示完成最大交易次数的客户详细信息
- javascript - 谷歌选择器选择文件回调
- python - 如何将字典列表添加到我的代码中,以便它可以正常运行?
- python - 如何删除 json 中的“转义斜线”?
- sql - 当数字 0.0 乘以负数字/整数时,BigQuery 产生负 (!) 零
- identityserver4 - IdentityServer4 与移动应用程序的谷歌身份验证?
- ios - 合并 - 订阅 PassthroughSubject 的发布者两次
- c++ - 两个默认构造函数,一个是公共的,一个是私有的