spring-cloud / spring-cloud-consul

Spring Cloud Consul
http://cloud.spring.io/spring-cloud-consul/
Apache License 2.0
805 stars 543 forks source link

Failed to bind properties under 'spring.cloud.consul.config' #820

Closed ritikshuklacse closed 1 year ago

ritikshuklacse commented 1 year ago

APPLICATION FAILED TO START


Description:

I have a springboot application in which I am trying to configure vault and consul with consul i am facing below error :

Failed to bind properties under 'spring.cloud.consul.config' to org.springframework.cloud.consul.config.ConsulConfigProperties:

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'consulConfigProperties': Could not bind properties to 'ConsulConfigProperties' : prefix=spring.cloud.consul.config, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'spring.cloud.consul.config' to org.springframework.cloud.consul.config.ConsulConfigProperties

Reason: javax.validation.UnexpectedTypeException: HV000030: No validator could be found for constraint 'javax.validation.constraints.NotEmpty' validating type 'java.lang.String'. Check configuration for 'dataKey'

Action:

Update your application's configuration

Now, here are the consul properties that I am setting in my bootstrap file

Consul Configuration

spring.cloud.consul.enabled=${CONSUL_ENABLE:true} spring.cloud.consul.host=${CONSUL_HOST:localhost} spring.cloud.consul.port=${CONSUL_PORT:8500} spring.cloud.consul.config.fail-fast=true spring.cloud.consul.config.enabled=true spring.cloud.consul.config.format=properties spring.cloud.consul.config.prefix=config spring.cloud.consul.config.name=${CONSUL_CONFIG:application}

spring.cloud.consul.config.acl-token=${CONSUL_ACL_TOKEN}

spring.cloud.consul.config.watch.wait-time=${CONSUL_QUERY_DELAY:55} spring.cloud.consul.config.data-key=application.properties spring.cloud.consul.discovery.fail-fast=true

here are the library versions that I am using springboot version : 2.7.8 spring cloud dependencies version : 2021.0.5 org.springframework.cloud:spring-cloud-starter-bootstrap:jar:3.1.5:compile org.springframework.cloud:spring-cloud-starter-vault-config:jar:3.1.1:compile +- org.springframework.cloud:spring-cloud-starter-consul-config:jar:3.1.1:compile +- org.springframework.cloud:spring-cloud-starter-consul:jar:3.1.2:compile +- org.springframework.cloud:spring-cloud-consul-core:jar:3.1.2:compile

ritikshuklacse commented 1 year ago

Screenshot 2023-06-05 at 7 58 39 PM

ritikshuklacse commented 1 year ago

There was a conflicting dependency for hibernate-validator, issue is resolved.