具有配置服务器的SpringBoot

时间:2020-09-28 14:12:45

标签: postgresql spring-boot microservices spring-boot-configuration

我隶属于springBoot,是微服务API和中央配置服务器。

我有一个用于微服务的配置服务器,因此它包含不同的配置,目前我的建议基于这些微服务之一。

实际上,它可以与通信服务器很好地通信,而问题出在我的配置中,我告诉它使用postgreSQL。

如果我不通过配置服务器并使用完全相同的设置,则将我的微服务与postgres结合使用不会出错。

如果我通过配置服务器,则出现以下错误:

2020-09-28 15:56:59.329  INFO 15528 --- [         task-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-09-28 15:56:59.332  INFO 15528 --- [  restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor  : Shutting down ExecutorService 'applicationTaskExecutor'
2020-09-28 15:56:59.339  INFO 15528 --- [  restartedMain] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
Exception in thread "task-2" org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'springApplicationAdminRegistrar': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:220)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)

我的boostrap.properties是:

spring.application.name=microservice-products
# Global URI application server
management.endpoints.web.exposure.include=refresh
spring.main.allow-bean-definition-overriding=true
spring.cloud.config.uri=http://localhost:9101

它运作良好是因为它说:

2020-09-28 15:56:53.892  INFO 15528 --- [  restartedMain]  c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at: http://localhost:9101

尤其是有关postgres的信息:

2020-09-28 15:56:58.497  INFO 15528 --- [         task-1] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect

0 个答案:

没有答案