Проблемы в решении заполнителей в bootstrap.properties после обновления до Springboot 2
Пружинная зависимость:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
Зависимость Spring-cloud:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Finchley.M8</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Ошибка при запуске -
2018-03-09 19:41:35.096 WARN 97916 --- [ main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'propertySourceBootstrapConfiguration': Unsatisfied dependency expressed through field 'propertySourceLocators'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'configServicePropertySource' defined in org.springframework.cloud.config.client.ConfigServiceBootstrapConfiguration: Unsatisfied dependency expressed through method 'configServicePropertySource' parameter 0; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'configClientProperties': Could not bind properties to 'ConfigClientProperties' : prefix=spring.cloud.config, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'spring.cloud.config.password' to java.lang.String
bootstrap.properties:
spring.cloud.config.failFast=true
spring.profiles.active=${ACTIVE_PROFILES:dev}
spring.cloud.config.uri=${CLOUD_CONFIG_URL:http://domainname/cloud-config}
spring.cloud.config.username=${CLOUD_CONFIG_USERNAME}
spring.cloud.config.password=${CLOUD_CONFIG_PASSWORD}
1 ответ
Решение
Понял это:
spring.cloud.config.username=${CLOUD_CONFIG_USERNAME}
spring.cloud.config.password=${CLOUD_CONFIG_PASSWORD}
должен быть изменен на -
spring.cloud.config.username=${CLOUD_CONFIG_USERNAME:}
spring.cloud.config.password=${CLOUD_CONFIG_PASSWORD:}
Обратите внимание на двоеточие в конце. Это раньше работало, хотя.