一、该问题的重现步骤是什么?
1. 创建一个独立于BladeX外的微服务,依赖于bladex框架,pom参考bladex的服务引入包
2. 创建common并参考blade-common,配置与bladex使用的同一个nacos
3. 将数据库相关的配置写在resource的配置文件中或者nacos中都无法正常连接数据库
*具体请参考步骤5中的补充图片
二、你期待的结果是什么?实际看到的又是什么?
期待的结果为:正常连接数据库并启动服务
实际的结果为:启动失败,Failed to determine suitable jdbc url
三、你正在使用的是什么产品,什么版本?在什么操作系统上?
正在使用的是BladeX 3.1.0 RELEASE,在windows10的idea上开发,nacos等组件安装在虚拟机的CentOS7上
四、请提供详细的错误堆栈信息,这很重要。
WARN 18552 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is java.lang.RuntimeException: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webMvcMetricsFilter' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfiguration.class]: Unsatisfied dependency expressed through method 'webMvcMetricsFilter' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'prometheusMeterRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusMetricsExportAutoConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSourcePoolMetadataMeterBinder' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/jdbc/DataSourcePoolMetricsAutoConfiguration$DataSourcePoolMetadataMetricsConfiguration.class]: Unsatisfied dependency expressed through method 'dataSourcePoolMetadataMeterBinder' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [com/alibaba/druid/spring/boot/autoconfigure/DruidDataSourceAutoConfigure.class]: Invocation of init method failed; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine suitable jdbc url
INFO 18552 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
ERROR 18552 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine suitable jdbc url
五、若有更多详细信息,请在下面提供。
参考https://sns.bladex.cn/q-5408.html的解决办法,在Configuration文件添加注解,开启动态数据库,未解决问题
正常填写数据库连接,如
jdbc:mysql://x.x.x.x:3306/xxx?serverTimezone=Asia/Shanghai&useSSL=false&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true
或者使用nacos中的
url: ${jcgkzx.datasource.dev.url}
或者干脆使用与bladex相同的数据库配置
url: ${blade.datasource.dev.url}
都无法正常连接到数据库
数据库无异常,bladex服务可以正常运行
扫一扫访问 Blade技术社区 移动端