xml文件配置成:
spring:
datasource:
username: root
password: 0916990
url: jdbc:mysql://localhost:3306/big_event?useSSL=false&serverTimezone=UTC&useUnicode=true&characterEncoding=utf8
driver-class-name: com.mysql.cj.jdbc.Driver
这样可以正确连接到数据库。
但是使用dynamic datasource配置多源数据库时,就有问题
xml配置:
spring:
datasource:
dynamic:
#设置默认的数据源或者数据源组,默认值即为mysql
primary: mysql
#严格匹配数据源,默认false. true未匹配到指定数据源时抛异常,false使用默认数据源
strict: false
datasource:
db1:
username: root
password: iptvaxfb2020end..
url: jdbc:mysql://master:3306/user?characterEncoding=utf-8&useSSL=false
driver-class-name: com.mysql.cj.jdbc.Driver
db2:
url: jdbc:clickhouse://master:8123/tag
driver-class-name: ru.yandex.clickhouse.ClickHouseDriver
data:
redis:
host: localhost
port: 6379
报错:
2024-04-11T14:43:35.031+08:00 ERROR 30168 --- [ 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 a suitable driver class
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 (no profiles are currently active).
pom文件maven相关依赖:
<!-- mybatis依赖-->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.4.1</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>3.4.1</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
<version>3.3.2</version>
</dependency>
<!-- mysql驱动依赖-->
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.30</version>
</dependency>
<!-- clickhouse坐标-->
<dependency>
<groupId>ru.yandex.clickhouse</groupId>
<artifactId>clickhouse-jdbc</artifactId>
<version>0.3.2</version> <!-- 使用适当的版本号 -->
</dependency>
想请问求教有大佬了解是什么问题吗?