Мы пытаемся добавить Spring Cloud Config Server в наш проект, чтобы перенастроить конфигурацию.
Мы создали сервер конфигурации, который подключается к репо Git и, кажется, работает правильно. Однако, когда мы запускаем пример клиента, мы получаем конфигурацию извлечения сообщений с сервера. Расположенная среда, но затем сообщение для установки свойства, которое мы установили в соответствующем файле yaml в git репо.
Сервер конфигурации bootStrap .yml
spring:
application:
name: configuration-service
server:
port: 8888
Сервер конфигурации application.yml
spring:
profiles:
active: dev
security:
user:
name: root
password: M5awantk
cloud:
config:
server:
git:
clone-on-start: true
uri: https://git.assembla.com/*********
username: ***********
password: ***********
Удар http://localhost: 8080 / служба уведомлений / по умолчанию дает следующее правильное значение
{
name: "notification-service",
profiles: [
"default"
],
label: null,
version: "21ee5025b232b812e0e64387cd577eeda0351214",
state: null,
propertySources: [
{
name: "https://git.assembla.com/pins-configuration.git/notification-service.yml",
source: {
spring.main.allow-bean-definition-overriding: true,
spring.application.name: "notification-service",
spring.zipkin.baseUrl: "http://localhost:9411/",
spring.jpa.properties.hibernate.cache.use_second_level_cache: true,
spring.jpa.properties.hibernate.cache.use_query_cache: true,
server.port: 8091,
server.compression.enabled: true,
server.compression.min-response-size: 2048,
server.compression.mime-types: "application/json,application/xml,text/html,text/plain",
eureka.instance.hostname: "localhost",
eureka.instance.port: 8761,
eureka.instance.leaseRenewalIntervalInSeconds: 3,
eureka.instance.instanceId:
"${spring.application.name}:${spring.application.instance_id:${random.value}}",
eureka.client.registryFetchIntervalSeconds: 5,
eureka.client.instanceInfoReplicationIntervalSeconds: 5,
eureka.client.initialInstanceInfoReplicationIntervalSeconds: 5,
eureka.client.serviceUrl.defaultZone:
"http://${eureka.instance.hostname}:${eureka.instance.port}/eureka/"
}
}
]
}
Клиент (именованное уведомление- service)
Клиент bootstrap .yml
spring:
cloud:
config:
uri: http://localhost:8888
username: root
password: M5awantk
name: notification-service
application:
name: notifcation-service
При запуске службы уведомлений кажется, что служба конфигурации и уведомление-service.yml, как и ожидалось, ожидаются, но затем мы получаем ошибка
Подумайте о переименовании одного из компонентов или включении переопределения, установив spring.main.allow-bean-definition-overriding = true
Хотя в уведомлении-service.yml есть следующее показывает, когда мы нажимаем http://localhost: 8080 / служба уведомлений / по умолчанию
spring.main.allow-bean-definition-overririd: true
Вывод на консоль при запуске служба уведомлений
2020-03-24 18:26:03.046 INFO [notifcation-service,,,] 24238 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8888
2020-03-24 18:26:04.847 INFO [notifcation-service,,,] 24238 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=notification-service, profiles=[default], label=null, version=21ee5025b232b812e0e64387cd577eeda0351214, state=null
2020-03-24 18:26:04.848 INFO [notifcation-service,,,] 24238 --- [ main] b.c.PropertySourceBootstrapConfiguration : Located property source: OriginTrackedCompositePropertySource {name='configService', propertySources=[MapPropertySource {name='configClient'}, OriginTrackedMapPropertySource {name='https://git.assembla.com/pins-configuration.git/notification-service.yml'}]}
2020-03-24 18:26:04.900 INFO [notifcation-service,,,] 24238 --- [ main] c.s.p.n.NotificationServiceApplication : The following profiles are active: dev
2020-03-24 18:26:06.237 INFO [notifcation-service,,,] 24238 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2020-03-24 18:26:06.464 INFO [notifcation-service,,,] 24238 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 217ms. Found 3 JPA repository interfaces.
2020-03-24 18:26:06.474 INFO [notifcation-service,,,] 24238 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2020-03-24 18:26:06.615 INFO [notifcation-service,,,] 24238 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 140ms. Found 21 JPA repository interfaces.
2020-03-24 18:26:06.616 WARN [notifcation-service,,,] 24238 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'jpaAuditingHandler' defined in null: Cannot register bean definition [Root bean: class [org.springframework.data.auditing.AuditingHandler]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] for bean 'jpaAuditingHandler': There is already [Root bean: class [org.springframework.data.auditing.AuditingHandler]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] bound.
2020-03-24 18:26:06.626 INFO [notifcation-service,,,] 24238 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-03-24 18:26:06.630 ERROR [notifcation-service,,,] 24238 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
The bean 'jpaAuditingHandler' could not be registered. A bean with that name has already been defined and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
N не уверен, что мы можем делать неправильно.
РЕДАКТИРОВАТЬ: мне удалось получить очень простое приложение, работающее только с одним набором свойств в соответствующем application.yml.
Интересно, связано ли это со свойствами, недоступными во времени, хотя из вывода консоли это не выглядит так.