Start error with yml
spring boot version 2.2 jdk 13 sharding 4.0.0-RC3
I searched most of the cases and configured them with properties But I used yml, but something went wrong
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
This is my configuration
shardingsphere:
datasource:
names: ds0,ds1
ds0:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://mysql.ciel.cl:1600/ds0?seUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: ciel
ds1:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://mysql.ciel.cl:1601/ds1?seUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: ciel
sharding:
default-database-strategy:
inline:
sharding-column: id
algorithm-expression: ds$->{id % 2}
tables:
t_order:
actual-data-nodes: ds$->{0..1}.t_order$->{0..2}
table-strategy:
inline:
sharding-column: id
algorithm-expression: t_order$->{id % 2}
key-generator: #
column: id
type: SNOWFLAKE
# t_order_item:
# actual-data-nodes: ds$->{0..1}.t_order_item$->{0..1}
# table-strategy:
# inline:
# sharding-column: order_id
# algorithm-expression: t_order_item$->{order_id % 2}
props:
sql:
show: true #
Hi! ShardingSphere supports mysql5 at this version! Your driver is mysql8.
4.0 version does not support mysql8?
To be exact, ShardingSphere's compatibility with MySQL 8 is not good.
Can you provide the exception info?
@cielswift Try to use 4.0.0 release?
@terrymanu

@terrymanu
2020-01-17 14:34:43.348 ERROR 7196 --- [ restartedMain] o.s.b.web.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException. Message: Error creating bean with name 'servletEndpointRegistrar' defined in class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration$WebMvcServletEndpointManagementContextConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar]: Factory method 'servletEndpointRegistrar' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'healthEndpoint' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Unsatisfied dependency expressed through method 'healthEndpoint' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'healthContributorRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthContributorRegistry]: Factory method 'healthContributorRegistry' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.jdbc.DataSourceHealthContributorAutoConfiguration': 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 a suitable driver class
2020-01-17 14:34:43.375 INFO 7196 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2020-01-17 14:34:43.388 WARN 7196 --- [ restartedMain] o.a.c.loader.WebappClassLoaderBase : The web application [producer] appears to have started a thread named [RxIoScheduler-1 (Evictor)] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
[email protected]/jdk.internal.misc.Unsafe.park(Native Method)
[email protected]/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:235)
[email protected]/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2123)
[email protected]/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1182)
[email protected]/java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:899)
[email protected]/java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1054)
[email protected]/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1114)
[email protected]/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[email protected]/java.lang.Thread.run(Thread.java:830)
2020-01-17 14:34:43.389 WARN 7196 --- [ restartedMain] o.a.c.loader.WebappClassLoaderBase : The web application [producer] appears to have started a thread named [lettuce-eventExecutorLoop-1-1] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
[email protected]/jdk.internal.misc.Unsafe.park(Native Method)
[email protected]/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:235)
[email protected]/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2123)
[email protected]/java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:458)
app//io.netty.util.concurrent.SingleThreadEventExecutor.takeTask(SingleThreadEventExecutor.java:289)
app//io.netty.util.concurrent.DefaultEventExecutor.run(DefaultEventExecutor.java:64)
app//io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1050)
app//io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
app//io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
[email protected]/java.lang.Thread.run(Thread.java:830)
2020-01-17 14:34:43.391 WARN 7196 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
2020-01-17 14:34:43.465 ERROR 7196 --- [ restartedMain] 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).
Disconnected from the target VM, address: '127.0.0.1:9200', transport: 'socket'
Process finished with exit code 1
shardingsphere: #分库分表
dataSources:
names: ds0,ds1 #指定数据库
ds0:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://mysql.ciel.cl:1600/ds0?seUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: ciel
ds1:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://mysql.ciel.cl:1601/ds1?seUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: ciel
sharding: # 分库策略 根据id取模确定数据进哪个数据库
default-database-strategy:
inline:
sharding-column: id
algorithm-expression: ds$->{id % 2}
tables: #具体分表策略 ,# 节点 ds0.t_order_0,ds0.t_order_1,ds1.t_order_0,ds1.t_order_1
t_order:
actual-data-nodes: ds$->{0..1}.t_order$->{0..2}
table-strategy:
inline:
sharding-column: id # 分表字段id
algorithm-expression: t_order$->{id % 2} # 分表策略 根据id取模,确定数据最终落在那个表中
key-generator: # 使用SNOWFLAKE算法生成主键
column: id
type: SNOWFLAKE
# t_order_item:
# actual-data-nodes: ds$->{0..1}.t_order_item$->{0..1}
# table-strategy:
# inline:
# sharding-column: order_id
# algorithm-expression: t_order_item$->{order_id % 2}
props:
sql:
show: true #打印sql
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>sharding-jdbc-spring-boot-starter</artifactId>
<version>4.0.0-RC3</version>
</dependency>
<!-- 分库分表 -->
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>sharding-jdbc-spring-namespace</artifactId>
<version>4.0.0-RC3</version>
</dependency>
@KomachiSion Yes, I see 4 in the official documentation, I think 3 is no longer maintained https://shardingsphere.apache.org/document/current/cn/manual/sharding-jdbc/usage/sharding/
@KomachiSion Yes, I see 4 in the official documentation, I think 3 is no longer maintained https://shardingsphere.apache.org/document/current/cn/manual/sharding-jdbc/usage/sharding/
Sorry, I mean can you have a try for 4.0.0 version, not 4.0.0-RC3.
4.0.0 version has release recently.
Any update?
Closed because no response anymore.
enhance it #5218, mysql8-client will be supported in 4.1.0
I have same problem. same pom。 same error。 How to solve the problem????
I have same problem too. same pom too。 same error too。 How to solve the problem????? My version is 4.1.1