配置多数据源加载不出数据源的url

Blade 未结 4 6073
渊鱼
渊鱼 2019-10-17 19:38

一、该问题的重现步骤是什么?

1. 修改默认property数据源配置(只要和默认配置格式不一样)

2. 或者在spring下一层级增加非数据源参数

3.


二、你期待的结果是什么?实际看到的又是什么?

多数据源配置成功,或者在本地配置有spring mail邮件所需参数


三、你正在使用的是什么产品,什么版本?在什么操作系统上?

bladex商业版,包域名自定义


四、请提供详细的错误堆栈信息,这很重要。

019-10-17 19:34:01.771  INFO 14072 --- [           main] faultConfiguringBeanFactoryPostProcessor : No bean named 'errorChannel' has been explicitly defined. Therefore, a default PublishSubscribeChannel will be created.
2019-10-17 19:34:01.800  INFO 14072 --- [           main] faultConfiguringBeanFactoryPostProcessor : No bean named 'integrationHeaderChannelRegistry' has been explicitly defined. Therefore, a default DefaultHeaderChannelRegistry will be created.
2019-10-17 19:34:02.788  INFO 14072 --- [           main] c.a.d.s.b.a.DruidDataSourceAutoConfigure : Init DruidDataSource
2019-10-17 19:34:03.021  WARN 14072 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sentinelBeanPostProcessor' defined in class path resource [com/alibaba/cloud/sentinel/custom/SentinelAutoConfiguration.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'transactionAdviceConfig': Unsatisfied dependency expressed through field 'transactionManager'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration$DataSourceTransactionManagerConfiguration': Unsatisfied dependency expressed through constructor 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
2019-10-17 19:34:03.049  INFO 14072 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
Disconnected from the target VM, address: '127.0.0.1:50672', transport: 'socket'
2019-10-17 19:34:03.062 ERROR 14072 --- [           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


Action:

Consider the following:
 If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
 If you have database settings to be loaded from a particular profile you may need to activate it (the profiles dev are currently active).


Process finished with exit code 1


五、若有更多详细信息,请在下面提供。

#数据源配置
spring:
  datasource:
#    url: ${blade.datasource.dev.url}
#    username: ${blade.datasource.dev.username}
#    password: ${blade.datasource.dev.password}
    dynamic:
      primary: master
      datasource:
        master:
          url: ${blade.datasource.dev.url}
          username: ${blade.datasource.dev.username}
          password: ${blade.datasource.dev.password}
          driver-class-name: com.mysql.cj.jdbc.Driver
        poistore:
          url: ${blade.datasource.dev.ucmurl}
          username: ${blade.datasource.dev.username}
          password: ${blade.datasource.dev.password}
          driver-class-name: com.mysql.cj.jdbc.Driver



4条回答
  •  jgx
    jgx (楼主)
    2022-01-08 22:34

    像楼主说的按照demo配置dev正常,但prod环境需要按“冰心”说的启动类额外加注解@SpringBootApplication(exclude = DruidDataSourceAutoConfigure.class)启动类加注解后,我在生存环境试了,一切正常

提交回复