一、该问题的重现步骤是什么?
1. 在pom.xml添加dynamic-datasource-spring-boot-starter
com.baomidou dynamic-datasource-spring-boot-starter
2. application-dev.yml配置数据源信息
#数据源配置 spring: datasource: dynamic: enabled: true primary: master #设置默认的数据源或者数据源组,默认值即为master strict: false #设置严格模式,默认false不启动. 启动后在未匹配到指定数据源时候会抛出异常,不启动则使用默认数据源. datasource: master: url: jdbc:mysql://localhost:3306/bladex?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&tinyInt1isBit=false&allowMultiQueries=true&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true username: root password: 123456 driver-class-name: com.mysql.cj.jdbc.Driver #tadb: #url: jdbc:oracle:thin:@127.0.0.1:1521:orcl #username: xxx #password: xxx #driver-class-name: oracle.jdbc.OracleDriver
二、你期待的结果是什么?实际看到的又是什么?
可通过dynamic-datasource动态切换数据源,按照dynamic-datasource进行配置报错
三、你正在使用的是什么产品,什么版本?在什么操作系统上?
BladeX、BladeX-Tool V2.7.0 windows 2016
四、请提供详细的错误堆栈信息,这很重要。
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2021-01-11 17:04:47.704 ERROR 1836 --- [ 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).
五、若有更多详细信息,请在下面提供。
扫一扫访问 Blade技术社区 移动端