Failed to bind properties under ‘spring.cloud.gateway.routes[0]‘ to org.springframework.cloud.gatewa

在做网关的时候启动报错:

Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug’ enabled.
2021-01-06 13:02:31.259 ERROR 21520 — [ main] o.s.b.d.LoggingFailureAnalysisReporter :


APPLICATION FAILED TO START


Description:

Failed to bind properties under ‘spring.cloud.gateway.routes[0]’ to org.springframework.cloud.gateway.route.RouteDefinition:

Reason: HV000030: No validator could be found for constraint 'javax.validation.constraints.NotEmpty' validating type 'java.util.List<org.springframework.cloud.gateway.handler.predicate.PredicateDefinition>'. Check configuration for 'predicates'

Action:

Update your application’s configuration

Process finished with exit code 1

解决办法:
因为我在common的项目里面已经添加了

org.hibernate
hibernate-validator
5.4.1.Final

而springboot2.2版本已经有了这个依赖,导致依赖冲突,解决办法:删除上面的这个依赖即可

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
### 回答1: 绑定到目标org.springframework.boot.context.properties.bind.bindexception时出错:无法将属性绑定到org.springframework.cloud.gateway.config.gatewayproperties下的“spring.cloud.gateway”失败。 ### 回答2: 这个错误是因为在Spring Boot应用程序中,当尝试绑定属性失败时,会抛出“org.springframework.boot.context.properties.bind.BindException”异常。在这种情况下,属性的绑定操作无法成功执行。 具体来说,你遇到的这个问题是因为尝试将'spring.cloud.gateway'属性绑定到Spring Cloud Gateway的配置类'org.springframework.cloud.gateway.config.GatewayProperties'时失败了。 这个问题可能有很多原因。其中一种可能性是,该属性在应用程序的配置文件中没有正确定义。或者,它可能与应用程序其他部分的配置发生冲突,在这种情况下需要仔细检查应用程序的配置,并确保它们相互兼容。 另外,可能还需要检查应用程序依赖项的版本。如果你的应用程序使用过时或不兼容的依赖项,那么它们可能会导致你遇到这种错误。 为了解决这个问题,你可以仔细检查你的应用程序配置和依赖项,并确保它们都兼容。如果你仍然无法解决问题,可以寻求专业帮助或咨询相关技术论坛。 ### 回答3: 这个错误提示是在Spring Boot应用程序中使用Spring Cloud Gateway组件时出现的。它通常是因为在绑定属性到`org.springframework.cloud.gateway.config.GatewayProperties`对象时出现了错误,导致`org.springframework.boot.context.properties.bind.BinderException`异常抛出。 在这个错误消息中,主要要注意的是`'spring.cloud.gateway'`,它表示的是Spring Cloud Gateway组件在`application.properties`或`application.yml`中的配置前缀。在绑定属性时,Spring Boot会自动读取以此前缀开头的属性,并尝试将它们绑定到`org.springframework.cloud.gateway.config.GatewayProperties`对象中的相应属性。 可能导致这种错误的原因有很多,具体取决于具体的属性配置。常见的问题包括: 1. 配置项拼写错误或不完整。即前缀或属性名称写错了,或属性值缺失。 2. 属性值类型不匹配。即属性的期望类型与实际值类型不一致,或者给定的属性值格式不正确。 3. 对象类型不匹配。即期望绑定到`GatewayProperties`对象的属性类型与实际不匹配,可能是因为版本不同或者配置文件格式不正确。 要解决这个问题,可以先检查配置文件中的属性拼写和格式是否正确。还可以尝试升级Spring Cloud GatewaySpring Boot的版本,以确保它们兼容。如果还是无法解决,可以尝试打开调试选项,获取更详细的错误信息,以找出问题所在。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值