Use 4.0.1 in spring boot 2.2.2 。get error Failed to configure a DataSource。
I use 4.0.1 in my spring boot 2.2.2
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.20</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>sharding-jdbc-spring-boot-starter</artifactId>
<version>4.0.1</version>
</dependency>
But i get error
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).
I change 4.0.0-RC1 version
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>sharding-jdbc-spring-boot-starter</artifactId>
<version>4.0.0-RC1</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.20</version>
</dependency>
The error is gone; I think that druid-spring-boot-starter have some wrong. But i don't find reason. What's the reason?
@jaedongjuly Could you try it again with the latest version?
@jaedongjuly Please do not use druid-spring-boot-starter Because it conflicts with the Sharding-datasource
@jaedongjuly Could you try it again with the latest version?
I use 4.1.0
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>sharding-jdbc-spring-boot-starter</artifactId>
<version>4.1.0</version>
</dependency>
and get same
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).
@jaedongjuly Please do not use
druid-spring-boot-starterBecause it conflicts with theSharding-datasource
I guess some wrong with druid-spring-boot-starter too . but i don't find reason . I want to know .
@jaedongjuly show you configuration,druid datasource property is url ? you config jdbc-url?
@jaedongjuly show you configuration,druid datasource property is url ? you config jdbc-url?
spring.shardingsphere.datasource.names=m1
spring.shardingsphere.datasource.m1.type=com.alibaba.druid.pool.DruidDataSource
spring.shardingsphere.datasource.m1.driver-class-name=com.mysql.jdbc.Driver
spring.shardingsphere.datasource.m1.url=jdbc:mysql://localhost:3306/course_db?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
spring.shardingsphere.datasource.m1.username=root
spring.shardingsphere.datasource.m1.password=
#配置course表
spring.shardingsphere.sharding.tables.course.actual-data-nodes=m1.course_$->{1..2}
#自增列名称,course用自增主键生成器
spring.shardingsphere.sharding.tables.course.key-generator.column=cid
# course 可使用用户自定义的列值生成器或选择内置类型:SNOWFLAKE/UUID
spring.shardingsphere.sharding.tables.course.key-generator.type=SNOWFLAKE
#分片列名称
spring.shardingsphere.sharding.tables.course.table-strategy.inline.sharding-column=cid
#分片算法行表达式,需符合groovy语法
spring.shardingsphere.sharding.tables.course.table-strategy.inline.algorithm-expression=course_$->{cid % 2 + 1}
#是否开启SQL显示,默认值: false
spring.shardingsphere.props.sql.show=true
This is only my application.properties.
where durid config?
where durid config?
I don't write druid config.
I use
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.20</version>
</dependency>
instead of
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.20</version>
</dependency>
My demo run well.
duplicated https://github.com/apache/shardingsphere/issues/5697