0

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

All dependencies look good to me, can someone help what might be causing this issue?`

spencergibb
  • 24,471
  • 6
  • 69
  • 75

1 Answers1

0

I Have some suggestion for you to check regarding your problem:

  1. make sure you defined the correct directory for data key in consul and proper config in your bootstrap.yml or properties file.
  2. make sure your variable type is matched with value that you provided.

3. there is a possibility that you have @NotEmpty on a non-string field.

Ali mjz
  • 13
  • 4