alibaba / Sentinel

A powerful flow control component enabling reliability, resilience and monitoring for microservices. (面向云原生微服务的高可用流控防护组件)
https://sentinelguard.io/
Apache License 2.0
22.18k stars 7.96k forks source link

引入 "spring-cloud-starter-alibaba-sentinel"依赖启动报错 #1922

Closed robben009 closed 3 years ago

robben009 commented 3 years ago

引入的pom如下:

org.springframework.cloud spring-cloud-dependencies Hoxton.SR8 pom import com.alibaba.cloud spring-cloud-alibaba-dependencies 2.2.3.RELEASE pom import org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-actuator org.springframework.boot spring-boot-configuration-processor true org.springframework.cloud spring-cloud-starter-openfeign com.alibaba.cloud spring-cloud-starter-alibaba-nacos-config com.alibaba.cloud spring-cloud-starter-alibaba-nacos-discovery com.alibaba.cloud spring-cloud-starter-alibaba-sentinel

配置文件bootstrap.yml:

server:
  servlet:
    context-path: /nacos-consumer
  port: 28085

nacosServerHost: ***

spring:
  application:
    name: nacos-consumer
  cloud:
    sentinel:
      transport:
        dashboard: ${nacosServerHost}:30002
    nacos:
      config:
        server-addr: ${nacosServerHost}:30000
        file-extension: yaml
        group: lalala
      discovery:
        server-addr: ${nacosServerHost}:30000
#        group: group1
#        namespace: 028aff0e-0f98-47f3-a4d4-497c4c7f062b

feign:
  hystrix:
    enabled: true  #保证了Feign的fallback机制
  client:
    config:
      default:
        connectTimeout: 5000 # 连接超时时间
        readTimeout: 5000   # 读超时时间
        loggerLevel: headers

已启动项目就报错: 2020-12-20 20:14:14.920 WARN 36436 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration': Unsatisfied dependency expressed through field 'properties'; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'spring.cloud.sentinel-com.alibaba.cloud.sentinel.SentinelProperties': Could not bind properties to 'SentinelProperties' : prefix=spring.cloud.sentinel, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is javax.validation.NoProviderFoundException: Unable to create a Configuration, because no Bean Validation provider could be found. Add a provider like Hibernate Validator (RI) to your classpath. 2020-12-20 20:14:14.939 INFO 36436 --- [ main] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2020-12-20 20:14:14.945 ERROR 36436 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :


APPLICATION FAILED TO START


Description:

The Bean Validation API is on the classpath but no implementation could be found

Action:

Add an implementation, such as Hibernate Validator, to the classpath

Disconnected from the target VM, address: '127.0.0.1:54370', transport: 'socket'

Process finished with exit code 1

去除依赖:

    <dependency>
        <groupId>com.alibaba.cloud</groupId>
        <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
    </dependency>

启动正常

是我配置文件配置的不对吗?

zhoushuai1119 commented 1 year ago

我也遇到同样的问题,请问你怎么解决的?