Giter Club home page Giter Club logo

shardingsphere-example's Introduction

Note: The examples had been transferred to shardingsphere/examples. All tags reserved, but will never be updated any more.

ShardingSphere-example

Example for 1.x please see tags in https://github.com/apache/incubator-shardingsphere/tree/${tag}/sharding-jdbc-example

Example for 2.x or 3.x or 4.x please see tags in https://github.com/apache/incubator-shardingsphere-example/tree/${tag}

Need attention

  • Please do not use dev branch to run your example, example of dev branch is not released yet.

  • The manual schema initial script is in https://github.com/apache/incubator-shardingsphere-example/blob/dev/src/resources/manual_schema.sql, please execute it before you first run the example.

  • Please make sure master-slave data sync on MySQL is running correctly. Otherwise this example will query empty data from slave.

Before start the example if you want use dev branch

Please make sure some dependencies from shardingsphere and shardingsphere-spi-impl have been installed since some examples depend on that. if you are a newbie for shardingsphere, you could prepare the dependencies as following:

1.download and install shardingsphere:

## download the code of shardingsphere
git clone https://github.com/apache/incubator-shardingsphere.git

## checkout a specific version, example is 4.0.0-RC1
cd incubator-shardingsphere && git checkout 4.0.0-RC1

## install the dependencies
mvn clean install -Prelease

2.download and install shardingsphere-spi-impl:

## download the code of shardingsphere-spi-impl
git clone https://github.com/OpenSharding/shardingsphere-spi-impl.git

## checkout a specific version, example is 4.0.0-RC1
cd shardingsphere-spi-impl && git checkout 4.0.0-RC1

## install the dependencies
mvn clean install

shardingsphere-example module design

project structure

shardingsphere-example
  ├── example-core
  │   ├── config-utility
  │   ├── example-api
  │   ├── example-raw-jdbc
  │   ├── example-spring-jpa
  │   └── example-spring-mybatis
  ├── sharding-jdbc-example
  │   ├── sharding-example
  │   │   ├── sharding-raw-jdbc-example
  │   │   ├── sharding-spring-boot-jpa-example
  │   │   ├── sharding-spring-boot-mybatis-example
  │   │   ├── sharding-spring-namespace-jpa-example
  │   │   └── sharding-spring-namespace-mybatis-example
  │   ├── orchestration-example
  │   │   ├── orchestration-raw-jdbc-example
  │   │   ├── orchestration-spring-boot-example
  │   │   └── orchestration-spring-namespace-example
  │   ├── transaction-example
  │   │   ├── transaction-2pc-xa-example
  │   │   └──transaction-base-seata-example
  │   ├── other-feature-example
  │   │   ├── hint-example
  │   │   └── encrypt-example
  ├── sharding-proxy-example
  │   └── sharding-proxy-boot-mybatis-example
  └── src/resources
        └── manual_schema.sql

Best practice for sharding data

  • sharding databases
  • sharding tables
  • sharding databases and tables
  • master-slave
  • sharding & master-slave

You can get more detail from sharding-example

Best practice for sharding + orchestration

  • using local configuration file for zookeeper/etcd & sharding
  • using register center(zookeeper/etcd)'s configuration for sharding

You can get more detail from orchestration-example

Best Practice for sharding + distribution-transaction

  • 2pc-xa transaction
  • base-seata transaction

You can get more detail from transaction-example

Best Practice for hint routing

You can get more detail from hint-example

Best Practice for data encrypt

You can get more detail from encrypt-example

Best Practice for APM

We will add APM example recently.

Best Practice for sharding-proxy.

We prefer to add a docker base example recently.

shardingsphere-example's People

Contributors

betterjava avatar cherrylzhao avatar geomonlin avatar gonwan avatar haetao avatar haocao avatar harvies avatar huangjian888 avatar it-noob avatar komachision avatar maxiaoguang64 avatar raigorjiang avatar taojintianxia avatar terrymanu avatar tristazero avatar tuohai666 avatar zkzong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shardingsphere-example's Issues

ShardingRule schema is hard code by "logic_db"

Which version of Sharding-Sphere do you using?

3.1.0

Which project do you using? Sharding-JDBC or Sharding-Proxy?

Sharding-JDBC

jar: sharding-jdbc-orchestration-spring-boot-starter
class:OrchestrationSpringBootConfiguration
method:isShardingRuleByRegistry
hard code:var3 = shardingOrchestrationFacade.getConfigService().isShardingRule("logic_db");

Expected behavior

it's need be configurable

Actual behavior

hard code "logic_db"

Reason analyze

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc

For bug report, please MUST provide the reproduce example codes (such as a github link).

报NullPointerException异常

百试一试都没有成功,请问下面错是什么原因?
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:

Error updating database. Cause: java.lang.NullPointerException

The error may involve defaultParameterMap

The error occurred while setting parameters

SQL: INSERT INTO mail ( id, send_id ) VALUES ( ?, ? )

Cause: java.lang.NullPointerException

at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:77)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
at com.sun.proxy.$Proxy168.insert(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:278)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:57)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
at com.sun.proxy.$Proxy170.insert(Unknown Source)
at com.julang2.opc.mail.MailSendBiz$1.process(MailSendBiz.java:90)
at com.julang2.opc.mail.MailSendBiz$1.process(MailSendBiz.java:59)
at com.julang2.opc.framework.biz.BizTemplate.doExecute(BizTemplate.java:80)
at com.julang2.opc.framework.biz.BizTemplate.execute(BizTemplate.java:56)
at com.julang2.opc.mail.MailSendBiz.sendTemplateMail(MailSendBiz.java:118)
at com.julang2.opc.mail.controller.MailSendController.sendTemplateMail(MailSendController.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.boot.web.filter.ApplicationContextHeaderFilter.doFilterInternal(ApplicationContextHeaderFilter.java:55)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:110)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.julang2.opc.framework.core.filters.HoldPrincipalFilter.doFilter(HoldPrincipalFilter.java:75)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:317)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:114)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationProcessingFilter.doFilter(OAuth2AuthenticationProcessingFilter.java:176)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:64)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:347)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:263)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:108)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.cloud.sleuth.instrument.web.TraceFilter.doFilter(TraceFilter.java:164)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:106)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)

以下是我的相关配置

依赖配置

<dependency> <groupId>commons-dbcp</groupId> <artifactId>commons-dbcp</artifactId> <version>1.4</version> </dependency>

<dependency> <groupId>io.shardingsphere</groupId> <artifactId>sharding-proxy</artifactId> <version>3.0.0.M1</version> </dependency>

<dependency> <groupId>io.shardingsphere</groupId> <artifactId>sharding-jdbc-spring-boot-starter</artifactId> <version>3.0.0.M1</version> </dependency>

dao配置

int insert(@param("mail")Mail mail);

xml配置

INSERT INTO mail ( id, send_id ) VALUES ( #{mail.id,jdbcType=BIGINT}, #{mail.sendId,jdbcType=BIGINT} )

分片数据源配置

sharding.jdbc.datasource.names=opc_mail
sharding.jdbc.datasource.opc_mail.type=org.apache.commons.dbcp.BasicDataSource
sharding.jdbc.datasource.opc_mail.driver-class-name=com.mysql.cj.jdbc.Driver
sharding.jdbc.datasource.opc_mail.url=jdbc:mysql://localhost:3306/opc_mail?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull
sharding.jdbc.datasource.opc_mail.username=opcmail
sharding.jdbc.datasource.opc_mail.password=Opc1123456@opcmail22
sharding.jdbc.datasource.opc_mail.hikari.readOnly=false
sharding.jdbc.datasource.opc_mail.connection-test-query=SELECT 1 FROM DUAL
sharding.jdbc.datasource.opc_mail.pool-name=springHikariCP
sharding.jdbc.datasource.opc_mail.idleTimeout=600000
sharding.jdbc.datasource.opc_mail.maxLifetime=1800000
sharding.jdbc.datasource.opc_mail.maximumPoolSize=64
sharding.jdbc.datasource.opc_mail.minimumIdle=12
#sharding.jdbc.datasource.schema = classpath:schema.sql
#spring.datasource.data = classpath:data.sql

sharding.jdbc.config.sharding.tables.mail.actual-data-nodes=opc_mail.mail_$->{0..4}
sharding.jdbc.config.sharding.tables.mail.table-strategy.inline.sharding-column=id
sharding.jdbc.config.sharding.tables.mail.table-strategy.inline.algorithm-expression=mail_$->{id % 5}
sharding.jdbc.config.sharding.tables.mail.key-generator-column-name=id

git clone fail by too long filename

error: unable to create file sharding-jdbc-orchestration-spring-example/sharding-jdbc-orchestration-spring-namespace-example/src/main/java/io/shardingjdbc/example.orchestration/spring/namespace/mybatis/OrchestrationSpringMybatisShardingAndMasterSlaveMain.java: Filename too long
error: unable to create file sharding-jdbc-orchestration-spring-example/sharding-jdbc-orchestration-spring-namespace-example/src/main/java/io/shardingjdbc/example.orchestration/spring/namespace/mybatis/OrchestrationSpringMybatisShardingDatabaseAndTableMain.java: Filename too long
error: unable to create file sharding-jdbc-orchestration-spring-example/sharding-jdbc-orchestration-spring-namespace-example/src/main/java/io/shardingjdbc/example.orchestration/spring/namespace/mybatis/OrchestrationSpringMybatisShardingDatabaseOnlyMain.java: Filename too long
fatal: unable to checkout working tree
warning: Clone succeeded, but checkout failed.

断网情况下, master-slave.xsd 无法找到

环境:

  • idea2017.2.5
  • jdk:1.8060
  • tomcat:8.5.14
  • sharding-jdbc:2.0.0
  • spring:4.2.4
    已经在Settings->Languages&Frameworks->Schemas and DTDs 里映射了本地下载的master-slave.xsd文件地址,
    但是Tomcat启动仍然报错:cvc-complex-type.2.4.c: 通配符的匹配很全面, 但无法找到元素 'master-slave:data-source' 的声明

自动生成主键为偶数

大神,你好。
我在测试sharding-jdbc-spring-boot-example 项目时,做分表测试(application-sharding.properties)。
使用自动生成主键:

INSERT INTO t_order (
user_id, status
)
VALUES (
#{userId,jdbcType=INTEGER},
#{status,jdbcType=VARCHAR}
)

发现生成的主键id都为偶数,数据只插入到t_order_0中,是不是哪里配置不对。以下为我的配置信息:
sharding.jdbc.datasource.names=ds_0,ds_1
sharding.jdbc.datasource.ds_0.type=org.apache.commons.dbcp.BasicDataSource
sharding.jdbc.datasource.ds_0.driver-class-name=com.mysql.jdbc.Driver
sharding.jdbc.datasource.ds_0.url=jdbc:mysql://localhost:3306/demo_ds_0
sharding.jdbc.datasource.ds_0.username=root
sharding.jdbc.datasource.ds_0.password=123456
sharding.jdbc.datasource.ds_1.type=org.apache.commons.dbcp.BasicDataSource
sharding.jdbc.datasource.ds_1.driver-class-name=com.mysql.jdbc.Driver
sharding.jdbc.datasource.ds_1.url=jdbc:mysql://localhost:3306/demo_ds_1
sharding.jdbc.datasource.ds_1.username=root
sharding.jdbc.datasource.ds_1.password=123456
sharding.jdbc.config.sharding.default-database-strategy.inline.sharding-column=user_id
sharding.jdbc.config.sharding.default-database-strategy.inline.algorithm-expression=ds_${user_id % 2}
sharding.jdbc.config.sharding.tables.t_order.actual-data-nodes=ds_${0..1}.t_order_${0..1}
sharding.jdbc.config.sharding.tables.t_order.table-strategy.inline.sharding-column=order_id
sharding.jdbc.config.sharding.tables.t_order.table-strategy.inline.algorithm-expression=t_order_${order_id % 2}
sharding.jdbc.config.sharding.tables.t_order.key-generator-column-name=order_id
sharding.jdbc.config.sharding.tables.t_order_item.actual-data-nodes=ds_${0..1}.t_order_item_${0..1}
sharding.jdbc.config.sharding.tables.t_order_item.table-strategy.inline.sharding-column=order_id
sharding.jdbc.config.sharding.tables.t_order_item.table-strategy.inline.algorithm-expression=t_order_item_${order_id % 2}
sharding.jdbc.config.sharding.tables.t_order_item.key-generator-column-name=order_item_id

Where I can operate, how can I know if SQL is DQL or DML?

For English only, other languages we will close it directly.

Please answer these questions before submitting your issue. Thanks!

Which version of Sharding-Sphere do you using?

Which project do you using? Sharding-JDBC or Sharding-Proxy?

Expected behavior

Actual behavior

Reason analyze

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc

For bug report, please MUST provide the reproduce example codes (such as a github link).

I used version 3.0.0.M4.
I used project Sharding-JDBC.
I used Sharding-JDBC in the original project. In order to ensure stability, I need to operate the original table when I operate the DML. I need to know whether the current SQL is a DML operation.

revise quickstart module name

  • sharding-data => sharding-example
  • sharding-orchestration => orchestration-example
  • sharding-transaction => transaction-example
  • replace quickStart => example

sharding-jdbc-spring-boot-data-mybatis-example 连接没全部释放

master分支,均采用默认配置。
修改 SpringBootDataMybatisMain

DemoService service = applicationContext.getBean(DemoService.class);
service.demo();
service.demo();

连接没有全部释放。第二次执行 demo() 时连接不够用了,默认 8 个连接。
AbstractConnectionAdapter

private final Map<String, Connection> cachedConnections = new HashMap();

这个 HashMap 感觉有点不太合适,还请各位大神赐教。

Exception:Missing the type of datasource configuration in orchestration configuration

i try to run a example in https://github.com/sharding-sphere/sharding-sphere-example with master tag. and this is the project path: 'sharding-sphere-example/sharding-jdbc-example/spring-boot-example/spring-boot-data-mybatis-example/'. but i failed. the log pointed out :

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [io/shardingsphere/jdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Missing the type of datasource configuration in orchestration configuration
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:732)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:474)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1247)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1096)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:535)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1135)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1062)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1421)
... 29 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [io/shardingsphere/jdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Missing the type of datasource configuration in orchestration configuration
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:590)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1247)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1096)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:535)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1135)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1062)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:818)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:724)
... 42 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Missing the type of datasource configuration in orchestration configuration
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:582)
... 55 common frames omitted
Caused by: java.lang.IllegalStateException: Missing the type of datasource configuration in orchestration configuration
at com.google.common.base.Preconditions.checkState(Preconditions.java:173)
at io.shardingsphere.jdbc.orchestration.spring.boot.OrchestrationSpringBootConfiguration.dataSource(OrchestrationSpringBootConfiguration.java:72)
at io.shardingsphere.jdbc.orchestration.spring.boot.OrchestrationSpringBootConfiguration$$EnhancerBySpringCGLIB$$7db26bc7.CGLIB$dataSource$1()
at io.shardingsphere.jdbc.orchestration.spring.boot.OrchestrationSpringBootConfiguration$$EnhancerBySpringCGLIB$$7db26bc7$$FastClassBySpringCGLIB$$53b5cd5a.invoke()
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:365)
at io.shardingsphere.jdbc.orchestration.spring.boot.OrchestrationSpringBootConfiguration$$EnhancerBySpringCGLIB$$7db26bc7.dataSource()
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
... 56 common frames omitted

i could not find other solution. could you give me some help?or maybe you can provide a new simpler example .

example can not use

tag: 3.0.0.M4
springboot-mybatis
spring.active=sharding

when spring boot starting,then happen error:
Missing the type of datasource configuration in orchestration configuration

sharding-jdbc-core-spring-namespace 2.1.0-SNAPSHOT 不能用

hello ,你好,我看到你的demo里引入sharding spring 的namespace的pom文件,我在我的项目里引用

<dependency>
                <groupId>io.shardingjdbc</groupId>
                <artifactId>sharding-jdbc-core-spring-namespace</artifactId>
                <version>2.1.0-SNAPSHOT</version>
            </dependency>

并不能正确引入
我该怎么办?

springboot集成sharding-jdbc 强制hint的example

请问有springboot集成sharding-jdbc 强制hint的example,我用spring-boot-nodep-mybatis-example进行改造如下,报如下错误:
The error occurred while setting parameters

SQL: CREATE TABLE IF NOT EXISTS t_order (order_id BIGINT AUTO_INCREMENT, user_id INT NOT NULL, status VARCHAR(50), PRIMARY KEY (order_id));

Cause: io.shardingsphere.core.exception.ShardingConfigurationException: Cannot find table rule and default data source with logic table: 't_order'

配置如下:
`sharding.jdbc.datasource.names=ds_0,ds_1

sharding.jdbc.datasource.ds_0.type=org.apache.commons.dbcp.BasicDataSource
sharding.jdbc.datasource.ds_0.driver-class-name=com.mysql.jdbc.Driver
sharding.jdbc.datasource.ds_0.url=jdbc:mysql://10.1.109.125:3306/demo_ds_0
sharding.jdbc.datasource.ds_0.username=root
sharding.jdbc.datasource.ds_0.password=123456

sharding.jdbc.datasource.ds_1.type=org.apache.commons.dbcp.BasicDataSource
sharding.jdbc.datasource.ds_1.driver-class-name=com.mysql.jdbc.Driver
sharding.jdbc.datasource.ds_1.url=jdbc:mysql://10.1.109.125:3306/demo_ds_1
sharding.jdbc.datasource.ds_1.username=root
sharding.jdbc.datasource.ds_1.password=123456

sharding.jdbc.config.sharding.database-strategy.hint.sharding-column.algorithm_class_name=io.shardingsphere.example.spring.boot.mybatis.nodep.MyHintShardingAlgorithm
`
我的场景是每个库是数据结构都是一样的,我只想根据系统类似于枚举开进行分库,比如传入一个固定的参数,指定到某个库。不需要配置每个表的路由规则。
请问这种要如何处理,非常感谢!

springboot的example中如何设置连接池的详细参数

sharding.jdbc.datasource.names=ds_master,ds_slave_0,ds_slave_1

sharding.jdbc.datasource.ds_master.type=org.apache.commons.dbcp.BasicDataSource
sharding.jdbc.datasource.ds_master.driver-class-name=com.mysql.jdbc.Driver
sharding.jdbc.datasource.ds_master.url=jdbc:mysql://localhost:3306/demo_ds_master
sharding.jdbc.datasource.ds_master.username=root
sharding.jdbc.datasource.ds_master.password=

sharding.jdbc.datasource.ds_slave_0.type=org.apache.commons.dbcp.BasicDataSource
sharding.jdbc.datasource.ds_slave_0.driver-class-name=com.mysql.jdbc.Driver
sharding.jdbc.datasource.ds_slave_0.url=jdbc:mysql://localhost:3306/demo_ds_slave_0
sharding.jdbc.datasource.ds_slave_0.username=root
sharding.jdbc.datasource.ds_slave_0.password=

##此处我想针对testOnBorrow、maxActive、minIdle参数 如何进行配置,谢谢

could staff members provide a way to launch the environment ASAP

For English only, other languages we will close it directly.

Please answer these questions before submitting your issue. Thanks!

Which version of Sharding-Sphere do you using?

ANY

Which project do you using? Sharding-JDBC or Sharding-Proxy?

incubator-shardingsphere-example

Expected behavior

since the example project need etcd / zookeeper / mysql etc as basic infrastructures. and It's really annoying to take too much time on download / config / execute a infrastructure environment, community members should take there limit time only on sharding-sphere it self .
now that container tech is so convenient, please try to simplify the infrastructures.
I want to provide related function, please assign this take to ME.

Actual behavior

we can use docker compose to launch several infrastructure in a very short period .
the mapping port is set in the docker-compse.yml, people could change the port if there takes conflict

Reason analyze

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc

Broadcast-table insert exception

Which version of Sharding-Sphere do you using?

3.1.0

Which project do you using? Sharding-JDBC or Sharding-Proxy?

Sharding-JDBC

Expected behavior

I want save the data to dataSouce0 and dataSouce1 by the broadcast-table,

But When I was testing the broadcast table,it was running an error !

Actual behavior

Exception :

org.springframework.orm.jpa.JpaSystemException: Unexpected row count: 2; expected: 1; nested exception is org.hibernate.jdbc.TooManyRowsAffectedException: Unexpected row count: 2; expected: 1
	at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:312)
	at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:223)
	at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:540)
	

Reason analyze

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc

Version:
Spring Boot 2.0.6+Sharding-Sphere 3.1.0+JPA

broadcast-table rule:
sharding.jdbc.config.sharding.broadcast-tables[0]=dictionary

Directionary class:

@Entity
public class Dictionary {
	@Id @GeneratedValue(strategy=GenerationType.AUTO)
	private long did;
	private String mykey;
	private String myvalue;
	private long uid;
}

Test code :

public void testBroadCast() {
		Dictionary dictionary = new Dictionary();
		dictionary.setMykey("systemName");
		dictionary.setMyvalue("kfit");
		dictionary.setUid(1000);
		dictionaryService.save(dictionary);
	}

For bug report, please MUST provide the reproduce example codes (such as a github link).

能否在maven pom.xml文件中直接添加 dependencies ?

目前example下载下来是无法运行的,要手动添加sharding-jdbc源码目录,或者添加maven dependencies:

<dependencies>
    <dependency>
        <groupId>io.shardingjdbc</groupId>
        <artifactId>sharding-jdbc-core</artifactId>
        <version>2.0.1</version>
    </dependency>
</dependencies>

不太方便,而且maven上面最新版本只有2.0.1,并不是2.0.2-SNAPSHOT

report dependency miss when compiling by using "mvn install"

[WARNING] The POM for io.shardingjdbc:sharding-jdbc-core:jar:2.0.0.M4-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] sharding-jdbc-example .............................. SUCCESS [ 5.600 s]
[INFO] sharding-jdbc-raw-jdbc-example ..................... SUCCESS [ 0.015 s]
[INFO] sharding-jdbc-raw-jdbc-java-example ................ FAILURE [ 0.135 s]

项目路径问题

image
用eclipse导入项目时,报错,查找原因是项目的代码目录用的是".",将"."改成"/"就好了。

spring-boot-data-mybatis-example 启动时候报错error : Missing the type of datasource configuration in orchestration configuration

本人使用的master分支, 只有在spring-boot-data-mybatis-example项目的 resources 中 application-sharding.properties中添加了数据库的密码。但是启动的时候总是报错Missing the type of datasource configuration in orchestration configuration。
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled. [ERROR] 2018-08-09 15:10:55,821 --main-- [org.springframework.boot.SpringApplication] Application startup failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'demoService': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'orderRepository' defined in file [D:\codes\sharding-sphere-example\sharding-jdbc-example\spring-boot-example\spring-boot-data-mybatis-example\target\classes\io\shardingsphere\example\spring\boot\mybatis\repository\OrderRepository.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [io/shardingsphere/jdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Missing the type of datasource configuration in orchestration configuration at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:321) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) at io.shardingsphere.example.spring.boot.mybatis.SpringBootDataMain.main(SpringBootDataMain.java:29) Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'orderRepository' defined in file [D:\codes\sharding-sphere-example\sharding-jdbc-example\spring-boot-example\spring-boot-data-mybatis-example\target\classes\io\shardingsphere\example\spring\boot\mybatis\repository\OrderRepository.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [io/shardingsphere/jdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Missing the type of datasource configuration in orchestration configuration at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1357) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1249) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:522) at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:496) at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:627) at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:169) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:318) ... 16 common frames omitted Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [io/shardingsphere/jdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Missing the type of datasource configuration in orchestration configuration at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749) at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:467) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1342) ... 29 common frames omitted Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [io/shardingsphere/jdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Missing the type of datasource configuration in orchestration configuration at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066) at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835) at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741) ... 42 common frames omitted Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Missing the type of datasource configuration in orchestration configuration at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ... 55 common frames omitted Caused by: java.lang.IllegalStateException: Missing the type of datasource configuration in orchestration configuration at com.google.common.base.Preconditions.checkState(Preconditions.java:173) at io.shardingsphere.jdbc.orchestration.spring.boot.OrchestrationSpringBootConfiguration.dataSource(OrchestrationSpringBootConfiguration.java:72) at io.shardingsphere.jdbc.orchestration.spring.boot.OrchestrationSpringBootConfiguration$$EnhancerBySpringCGLIB$$22f821c8.CGLIB$dataSource$1(<generated>) at io.shardingsphere.jdbc.orchestration.spring.boot.OrchestrationSpringBootConfiguration$$EnhancerBySpringCGLIB$$22f821c8$$FastClassBySpringCGLIB$$fe7dc063.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:356) at io.shardingsphere.jdbc.orchestration.spring.boot.OrchestrationSpringBootConfiguration$$EnhancerBySpringCGLIB$$22f821c8.dataSource(<generated>) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ... 56 common frames omitted Disconnected from the target VM, address: '127.0.0.1:50170', transport: 'socket'

image

这个项目都mvn clean package成功过的,然后才启动SpringBootDataMain。我不清楚这个是我本地电脑的问题还是其他原因,因为我这边是公司和家里电脑都是出现了这个问题,所以提了出来。请给与指点。

Missing the type of datasource configuration in orchestration configuration [3.0.0.M4]

Sorry, there are still some errors. When the project relies on orchestration, then orchestration must be configured in the configuration.

When I use sharding active,Project start error.

refer to :apache/shardingsphere#1319

[ERROR] 2018-10-03 14:50:42,525 --main-- [org.springframework.boot.SpringApplication] Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'demoService': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'orderRepository' defined in file [/Users/Jack/microservices/sharding-sphere-example/sharding-jdbc-example/spring-boot-example/spring-boot-data-mybatis-example/target/classes/io/shardingsphere/example/spring/boot/mybatis/repository/OrderRepository.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Missing the type of datasource configuration in orchestration configuration
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:321)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:314)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151)
at io.shardingsphere.example.spring.boot.mybatis.SpringBootDataMain.main(SpringBootDataMain.java:29)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'orderRepository' defined in file [/Users/Jack/microservices/sharding-sphere-example/sharding-jdbc-example/spring-boot-example/spring-boot-data-mybatis-example/target/classes/io/shardingsphere/example/spring/boot/mybatis/repository/OrderRepository.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Missing the type of datasource configuration in orchestration configuration
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1357)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1249)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:522)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:496)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:627)
at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:169)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:318)
... 16 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Missing the type of datasource configuration in orchestration configuration
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:467)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1342)
... 29 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Missing the type of datasource configuration in orchestration configuration
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
... 42 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Missing the type of datasource configuration in orchestration configuration
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
... 55 common frames omitted
Caused by: java.lang.IllegalStateException: Missing the type of datasource configuration in orchestration configuration
at com.google.common.base.Preconditions.checkState(Preconditions.java:173)
at io.shardingsphere.shardingjdbc.orchestration.spring.boot.OrchestrationSpringBootConfiguration.dataSource(OrchestrationSpringBootConfiguration.java:78)
at io.shardingsphere.shardingjdbc.orchestration.spring.boot.OrchestrationSpringBootConfiguration$$EnhancerBySpringCGLIB$$30d3fb00.CGLIB$dataSource$0()
at io.shardingsphere.shardingjdbc.orchestration.spring.boot.OrchestrationSpringBootConfiguration$$EnhancerBySpringCGLIB$$30d3fb00$$FastClassBySpringCGLIB$$1b944149.invoke()
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358)
at io.shardingsphere.shardingjdbc.orchestration.spring.boot.OrchestrationSpringBootConfiguration$$EnhancerBySpringCGLIB$$30d3fb00.dataSource()
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
... 56 common frames omitted
Disconnected from the target VM, address: '127.0.0.1:58820', transport: 'socket'

clone has error: unable to create file

$ git clone https://github.com/shardingjdbc/sharding-jdbc-example.git
Cloning into 'sharding-jdbc-example'...
remote: Counting objects: 3496, done.
remote: Compressing objects: 100% (172/172), done.
Receiving objecremote: Total 3496 (delta 94), reused 320 (delta 67), pack-reused 3134
Receiving objects: 100% (3496/3496), 342.15 KiB | 73.00 KiB/s, done.
Resolving deltas: 100% (1305/1305), done.
error: unable to create file sharding-jdbc-orchestration-spring-example/sharding-jdbc-orchestration-etcd-spring-namespace-example/src/main/java/io/shardingjdbc/example/orchestration/spring/namespace/mybatis/OrchestrationSpringMybatisMasterSlaveOnlyMain.java: Filename too long
error: unable to create file sharding-jdbc-orchestration-spring-example/sharding-jdbc-orchestration-etcd-spring-namespace-example/src/main/java/io/shardingjdbc/example/orchestration/spring/namespace/mybatis/OrchestrationSpringMybatisShardingAndMasterSlaveMain.java: Filename too long
error: unable to create file sharding-jdbc-orchestration-spring-example/sharding-jdbc-orchestration-etcd-spring-namespace-example/src/main/java/io/shardingjdbc/example/orchestration/spring/namespace/mybatis/OrchestrationSpringMybatisShardingDatabaseAndTableMain.java: Filename too long
error: unable to create file sharding-jdbc-orchestration-spring-example/sharding-jdbc-orchestration-etcd-spring-namespace-example/src/main/java/io/shardingjdbc/example/orchestration/spring/namespace/mybatis/OrchestrationSpringMybatisShardingDatabaseOnlyMain.java: Filename too long
error: unable to create file sharding-jdbc-orchestration-spring-example/sharding-jdbc-orchestration-etcd-spring-namespace-example/src/main/java/io/shardingjdbc/example/orchestration/spring/namespace/mybatis/OrchestrationSpringMybatisShardingTableOnlyMain.java: Filename too long
error: unable to create file sharding-jdbc-orchestration-spring-example/sharding-jdbc-orchestration-etcd-spring-namespace-example/src/main/java/io/shardingjdbc/example/orchestration/spring/namespace/mybatis/algorithm/PreciseModuloDatabaseShardingAlgorithm.java: Filename too long
error: unable to create file sharding-jdbc-orchestration-spring-example/sharding-jdbc-orchestration-etcd-spring-namespace-example/src/main/java/io/shardingjdbc/example/orchestration/spring/namespace/mybatis/algorithm/PreciseModuloTableShardingAlgorithm.java: Filename too long
error: unable to create file sharding-jdbc-orchestration-spring-example/sharding-jdbc-orchestration-etcd-spring-namespace-example/src/main/java/io/shardingjdbc/example/orchestration/spring/namespace/mybatis/repository/OrderItemRepository.java: Filename too long
error: unable to create file sharding-jdbc-orchestration-spring-example/sharding-jdbc-orchestration-zookeeper-spring-namespace-example/src/main/java/io/shardingjdbc/example/orchestration/spring/namespace/mybatis/OrchestrationSpringMybatisMasterSlaveOnlyMain.java: Filename too long
error: unable to create file sharding-jdbc-orchestration-spring-example/sharding-jdbc-orchestration-zookeeper-spring-namespace-example/src/main/java/io/shardingjdbc/example/orchestration/spring/namespace/mybatis/OrchestrationSpringMybatisShardingAndMasterSlaveMain.java: Filename too long
error: unable to create file sharding-jdbc-orchestration-spring-example/sharding-jdbc-orchestration-zookeeper-spring-namespace-example/src/main/java/io/shardingjdbc/example/orchestration/spring/namespace/mybatis/OrchestrationSpringMybatisShardingDatabaseAndTableMain.java: Filename too long
error: unable to create file sharding-jdbc-orchestration-spring-example/sharding-jdbc-orchestration-zookeeper-spring-namespace-example/src/main/java/io/shardingjdbc/example/orchestration/spring/namespace/mybatis/OrchestrationSpringMybatisShardingDatabaseOnlyMain.java: Filename too long
error: unable to create file sharding-jdbc-orchestration-spring-example/sharding-jdbc-orchestration-zookeeper-spring-namespace-example/src/main/java/io/shardingjdbc/example/orchestration/spring/namespace/mybatis/OrchestrationSpringMybatisShardingTableOnlyMain.java: Filename too long
error: unable to create file sharding-jdbc-orchestration-spring-example/sharding-jdbc-orchestration-zookeeper-spring-namespace-example/src/main/java/io/shardingjdbc/example/orchestration/spring/namespace/mybatis/algorithm/PreciseModuloDatabaseShardingAlgorithm.java: Filename too long
error: unable to create file sharding-jdbc-orchestration-spring-example/sharding-jdbc-orchestration-zookeeper-spring-namespace-example/src/main/java/io/shardingjdbc/example/orchestration/spring/namespace/mybatis/algorithm/PreciseModuloTableShardingAlgorithm.java: Filename too long
error: unable to create file sharding-jdbc-orchestration-spring-example/sharding-jdbc-orchestration-zookeeper-spring-namespace-example/src/main/java/io/shardingjdbc/example/orchestration/spring/namespace/mybatis/repository/OrderItemRepository.java: Filename too long
error: unable to create file sharding-jdbc-orchestration-spring-example/sharding-jdbc-orchestration-zookeeper-spring-namespace-example/src/main/java/io/shardingjdbc/example/orchestration/spring/namespace/mybatis/repository/OrderRepository.java: Filename too long
fatal: unable to checkout working tree
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry the checkout with 'git checkout -f HEAD'

Cannot correctly sharding table

For English only, other languages we will close it directly.

Please answer these questions before submitting your issue. Thanks!

Which version of Sharding-Sphere do you using?

3.0.0

Which project do you using? Sharding-JDBC or Sharding-Proxy?

run demo
io.shardingsphere.example.spring.namespace.mybatis.nodep
SpringNamespaceExample.java

private static ShardingType type = ShardingType.SHARDING_TABLES;

Expected behavior

Actual behavior

Not executed correctly shardingtable

10 rows of data in t_order_0
274539799358996480 1 INSERT_TEST
274539799925227520 2 INSERT_TEST
274539800344657920 3 INSERT_TEST
274539800743116800 4 INSERT_TEST
274539801149964288 5 INSERT_TEST
274539801548423168 6 INSERT_TEST
274539801946882048 7 INSERT_TEST
274539802349535232 8 INSERT_TEST
274539802756382720 9 INSERT_TEST
274539803171618816 10 INSERT_TEST

0 row of data in t_order_1

Reason analyze

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc

For bug report, please MUST provide the reproduce example codes (such as a github link).

读写分离从库没数据

Runing according to example and document,the spring boot version of mine is 2.0.3,and the version of sharding jdbc is sharding-jdbc-spring-boot-starter-3.0.0.M1, but there aren’t datas in salve. which part is wrong?

springboot的example中如何设置连接池的详细参数

请问:类似以下druid连接池特有的配置项如何处理?
spring.datasource.druid.web-stat-filter.enabled=true
spring.datasource.druid.web-stat-filter.url-pattern=/*
spring.datasource.druid.web-stat-filter.exclusions=.js,.gif,.jpg,.png,.css,.ico,/druid/*
spring.datasource.druid.web-stat-filter.session-stat-enable=true
spring.datasource.druid.web-stat-filter.session-stat-max-count=1000
spring.datasource.druid.web-stat-filter.principal-session-name=
spring.datasource.druid.web-stat-filter.principal-cookie-name=
spring.datasource.druid.web-stat-filter.profile-enable=true

spring.datasource.druid.stat-view-servlet.enabled=true
spring.datasource.druid.stat-view-servlet.url-pattern=/druid/*
##禁用HTML页面上的“Reset All”功能
spring.datasource.druid.stat-view-servlet.reset-enable=true
spring.datasource.druid.stat-view-servlet.login-username=druid
spring.datasource.druid.stat-view-servlet.login-password=druid

jpa 建表改为update 执行错误

spring.jpa.properties.hibernate.hbm2ddl.auto=update

Unable to execute schema management to JDBC target [create table t_order (order_id bigint not null auto_increment, status varchar(255), user_id integer, primary key (order_id))]
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 't_order_0' already exists

怎么自己去创建表了

sharding-sphere springboot +mybatis cannot run (active=sharding)

version: 3.0.0.M1
project:Sharding-JDBC
spring.active=sharding

expect behavior: spring boot started normally
actual behavior: Cannot determine embedded database driver class for database type NONE

Reason analyze:
spring boot must be need a database configuration?

error: Cannot determine embedded database driver class for database type NONE

Which project do you using? Sharding-JDBC or Sharding-Proxy?

When I cloned the repository and tried to run the module: spring-boot-data-mybatis-example, I encountered the below problems.

Reason analyze

I think its main cause is the lack of datasource configuration. Should I need to add datasource configuration manually?

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc

  1. midified active profile to masterslave.
  2. ran the main fun of SpringBootDataMain class.

For bug report, please MUST provide the reproduce example codes (such as a github link).

"C:\Program Files\Java\jdk1.8.0_181\bin\java.exe" -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=59278 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=localhost -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2018.2.2\lib\idea_rt.jar=59279:C:\Program Files\JetBrains\IntelliJ IDEA 2018.2.2\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_181\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_181\jre\lib\rt.jar;D:\git\sharding-sphere-example\sharding-jdbc-example\spring-boot-example\spring-boot-data-mybatis-example\target\classes;C:\Users\user.m2\repository\org\mybatis\spring\boot\mybatis-spring-boot-starter\1.3.0\mybatis-spring-boot-starter-1.3.0.jar;C:\Users\user.m2\repository\org\springframework\boot\spring-boot-starter-jdbc\1.5.2.RELEASE\spring-boot-starter-jdbc-1.5.2.RELEASE.jar;C:\Users\user.m2\repository\org\apache\tomcat\tomcat-jdbc\8.5.11\tomcat-jdbc-8.5.11.jar;C:\Users\user.m2\repository\org\apache\tomcat\tomcat-juli\8.5.11\tomcat-juli-8.5.11.jar;C:\Users\user.m2\repository\org\springframework\spring-jdbc\4.3.7.RELEASE\spring-jdbc-4.3.7.RELEASE.jar;C:\Users\user.m2\repository\org\springframework\spring-beans\4.3.7.RELEASE\spring-beans-4.3.7.RELEASE.jar;C:\Users\user.m2\repository\org\springframework\spring-tx\4.3.7.RELEASE\spring-tx-4.3.7.RELEASE.jar;C:\Users\user.m2\repository\org\mybatis\spring\boot\mybatis-spring-boot-autoconfigure\1.3.0\mybatis-spring-boot-autoconfigure-1.3.0.jar;C:\Users\user.m2\repository\org\mybatis\mybatis\3.4.4\mybatis-3.4.4.jar;C:\Users\user.m2\repository\org\mybatis\mybatis-spring\1.3.1\mybatis-spring-1.3.1.jar;C:\Users\user.m2\repository\org\springframework\boot\spring-boot-starter\1.5.0.RELEASE\spring-boot-starter-1.5.0.RELEASE.jar;C:\Users\user.m2\repository\org\springframework\boot\spring-boot\1.5.0.RELEASE\spring-boot-1.5.0.RELEASE.jar;C:\Users\user.m2\repository\org\springframework\spring-context\4.3.6.RELEASE\spring-context-4.3.6.RELEASE.jar;C:\Users\user.m2\repository\org\springframework\spring-aop\4.3.6.RELEASE\spring-aop-4.3.6.RELEASE.jar;C:\Users\user.m2\repository\org\springframework\spring-expression\4.3.6.RELEASE\spring-expression-4.3.6.RELEASE.jar;C:\Users\user.m2\repository\org\springframework\boot\spring-boot-autoconfigure\1.5.0.RELEASE\spring-boot-autoconfigure-1.5.0.RELEASE.jar;C:\Users\user.m2\repository\org\springframework\boot\spring-boot-starter-logging\1.5.0.RELEASE\spring-boot-starter-logging-1.5.0.RELEASE.jar;C:\Users\user.m2\repository\org\slf4j\jul-to-slf4j\1.7.22\jul-to-slf4j-1.7.22.jar;C:\Users\user.m2\repository\org\slf4j\log4j-over-slf4j\1.7.22\log4j-over-slf4j-1.7.22.jar;C:\Users\user.m2\repository\org\springframework\spring-core\4.3.6.RELEASE\spring-core-4.3.6.RELEASE.jar;C:\Users\user.m2\repository\org\yaml\snakeyaml\1.17\snakeyaml-1.17.jar;C:\Users\user.m2\repository\com\zaxxer\HikariCP-java7\2.4.11\HikariCP-java7-2.4.11.jar;C:\Users\user.m2\repository\org\slf4j\slf4j-api\1.7.21\slf4j-api-1.7.21.jar;C:\Users\user.m2\repository\commons-dbcp\commons-dbcp\1.4\commons-dbcp-1.4.jar;C:\Users\user.m2\repository\commons-pool\commons-pool\1.5.4\commons-pool-1.5.4.jar;C:\Users\user.m2\repository\mysql\mysql-connector-java\5.1.42\mysql-connector-java-5.1.42.jar;C:\Users\user.m2\repository\postgresql\postgresql\9.1-901-1.jdbc4\postgresql-9.1-901-1.jdbc4.jar;C:\Users\user.m2\repository\org\slf4j\jcl-over-slf4j\1.7.7\jcl-over-slf4j-1.7.7.jar;C:\Users\user.m2\repository\ch\qos\logback\logback-classic\1.2.0\logback-classic-1.2.0.jar;C:\Users\user.m2\repository\ch\qos\logback\logback-core\1.2.0\logback-core-1.2.0.jar" io.shardingsphere.example.spring.boot.mybatis.SpringBootDataMain

. ____ _ __ _ _
/\ / ' __ _ () __ __ _ \ \ \
( ( )_
_ | '_ | '| | ' / ` | \ \ \
\/ )| |)| | | | | || (| | ) ) ) )
' |
| .__|| ||| |_, | / / / /
=========|
|==============|/=////
:: Spring Boot :: (v1.5.0.RELEASE)

[INFO ] 2018-09-27 08:28:09,713 --main-- [io.shardingsphere.example.spring.boot.mybatis.SpringBootDataMain] Starting SpringBootDataMain on DESKTOP-4CI1GST with PID 27964 (D:\git\sharding-sphere-example\sharding-jdbc-example\spring-boot-example\spring-boot-data-mybatis-example\target\classes started by user in D:\git\sharding-sphere-example)
[INFO ] 2018-09-27 08:28:09,729 --main-- [io.shardingsphere.example.spring.boot.mybatis.SpringBootDataMain] The following profiles are active: masterslave
[INFO ] 2018-09-27 08:28:09,776 --main-- [org.springframework.context.annotation.AnnotationConfigApplicationContext] Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@5906ebcb: startup date [Thu Sep 27 08:28:09 CST 2018]; root of context hierarchy
[INFO ] 2018-09-27 08:28:10,172 --main-- [org.springframework.beans.factory.support.DefaultListableBeanFactory] Overriding bean definition for bean 'dataSource' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Dbcp; factoryMethodName=dataSource; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Dbcp.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Hikari; factoryMethodName=dataSource; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]]
[INFO ] 2018-09-27 08:28:10,172 --main-- [org.springframework.beans.factory.support.DefaultListableBeanFactory] Overriding bean definition for bean 'dataSource' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Hikari; factoryMethodName=dataSource; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Tomcat; factoryMethodName=dataSource; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Tomcat.class]]
[WARN ] 2018-09-27 08:28:10,478 --main-- [org.springframework.context.annotation.AnnotationConfigApplicationContext] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'demoService': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'orderRepository' defined in file [D:\git\sharding-sphere-example\sharding-jdbc-example\spring-boot-example\spring-boot-data-mybatis-example\target\classes\io\shardingsphere\example\spring\boot\mybatis\repository\OrderRepository.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Tomcat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (the profiles "masterslave2" are currently active).
[INFO ] 2018-09-27 08:28:10,478 --main-- [org.springframework.boot.autoconfigure.logging.AutoConfigurationReportLoggingInitializer]

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
[ERROR] 2018-09-27 08:28:10,494 --main-- [org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter]


APPLICATION FAILED TO START


Description:

Cannot determine embedded database driver class for database type NONE

Action:

If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (the profiles "masterslave" are currently active).

Process finished with exit code 1

Do I have to configure orchestration?

Hi,
I'am using sharding-sphere-example on branch master ,base on sharding-sphere 3.0.0.M4.
When I launch the spring-boot-jpa-example application, it will prompted me with

Missing the type of datasource configuration in orchestration configuration.

I did not modify application.properties and application-sharding.properties.And I don't want to use Zookeeper or etcd either.
Here is my log trace:

[INFO ] 2018-10-22 14:05:04,483 --main-- [io.shardingsphere.example.spring.boot.jpa.SpringBootDataMain] The following profiles are active: sharding 
[WARN ] 2018-10-22 14:05:05,341 --main-- [org.springframework.context.annotation.AnnotationConfigApplicationContext] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': 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 [io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Missing the type of datasource configuration in orchestration configuration 
Disconnected from the target VM, address: '127.0.0.1:64088', transport: 'socket'
[ERROR] 2018-10-22 14:05:05,354 --main-- [org.springframework.boot.SpringApplication] Application startup failed 
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': 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 [io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Missing the type of datasource configuration in orchestration configuration
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:189)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1193)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1095)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:372)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1081)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:856)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:314)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151)
	at io.shardingsphere.example.spring.boot.jpa.SpringBootDataMain.main(SpringBootDataMain.java:29)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [io/shardingsphere/shardingjdbc/orchestration/spring/boot/OrchestrationSpringBootConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Missing the type of datasource configuration in orchestration configuration
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
	at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835)
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
	... 27 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Missing the type of datasource configuration in orchestration configuration
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
	... 40 common frames omitted
Caused by: java.lang.IllegalStateException: Missing the type of datasource configuration in orchestration configuration
	at com.google.common.base.Preconditions.checkState(Preconditions.java:173)
	at io.shardingsphere.shardingjdbc.orchestration.spring.boot.OrchestrationSpringBootConfiguration.dataSource(OrchestrationSpringBootConfiguration.java:78)
	at io.shardingsphere.shardingjdbc.orchestration.spring.boot.OrchestrationSpringBootConfiguration$$EnhancerBySpringCGLIB$$4125044c.CGLIB$dataSource$0(<generated>)
	at io.shardingsphere.shardingjdbc.orchestration.spring.boot.OrchestrationSpringBootConfiguration$$EnhancerBySpringCGLIB$$4125044c$$FastClassBySpringCGLIB$$630c5154.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:356)
	at io.shardingsphere.shardingjdbc.orchestration.spring.boot.OrchestrationSpringBootConfiguration$$EnhancerBySpringCGLIB$$4125044c.dataSource(<generated>)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
	... 41 common frames omitted

Can u tell me how to turn off the orchestration configuration? thanks a lot

sharding-column是否只能是Number或其子类

请问sharding-column是否只能是Number或其子类?谢谢!

private GeneratedKey getGenerateKey(final ShardingRule shardingRule, final InsertStatement insertStatement, final List<Object> parameters) {
        GeneratedKey result = null;
        if (-1 != insertStatement.getGenerateKeyColumnIndex()) {
            for (GeneratedKeyCondition generatedKeyCondition : insertStatement.getGeneratedKeyConditions()) {
                if (null == result) {
                    result = new GeneratedKey(generatedKeyCondition.getColumn());
                }
                if (-1 == generatedKeyCondition.getIndex()) {
                    result.getGeneratedKeys().add(generatedKeyCondition.getValue());
                } else {
                    // 看这里是强转为Number
                    result.getGeneratedKeys().add((Number) parameters.get(generatedKeyCondition.getIndex()));
                }
            }
            return result;
        }
        String logicTableName = insertStatement.getTables().getSingleTableName();
        Optional<TableRule> tableRule = shardingRule.tryFindTableRuleByLogicTable(logicTableName);
        if (!tableRule.isPresent()) {
            return null;
        }
        Optional<Column> generateKeyColumn = shardingRule.getGenerateKeyColumn(logicTableName);
        if (generateKeyColumn.isPresent()) {
            result = new GeneratedKey(generateKeyColumn.get());
            for (int i = 0; i < insertStatement.getInsertValues().getInsertValues().size(); i++) {
                result.getGeneratedKeys().add(shardingRule.generateKey(logicTableName));
            }
        }
        return result;
    }```

请问是否支持数据源热加载?

你好, 我看example里面都是配置了两个已知数据源, 我需要在项目不重启的情况下添加第三个数据源, 请问哪块代码可以参考?

run mybatis SpringBootStarterExample.java ,why all orderId return odd

why all orderId is odd,and order_item_id is even;
like this

order_item_id:307459545343459328, order_id: 307459545276350465, user_id: 2, status: INSERT_TEST
order_item_id:307459545553174528, order_id: 307459545511231489, user_id: 4, status: INSERT_TEST
order_item_id:307459545762889728, order_id: 307459545708363777, user_id: 6, status: INSERT_TEST
order_item_id:307459545968410624, order_id: 307459545922273281, user_id: 8, status: INSERT_TEST
order_item_id:307459546190708736, order_id: 307459546144571393, user_id: 10, status: INSERT_TEST
order_item_id:307459546459144192, order_id: 307459546413006849, user_id: 12, status: INSERT_TEST
order_item_id:307459546673053696, order_id: 307459546626916353, user_id: 14, status: INSERT_TEST
order_item_id:307459546912129024, order_id: 307459546861797377, user_id: 16, status: INSERT_TEST
order_item_id:307459547147010048, order_id: 307459547084095489, user_id: 18, status: INSERT_TEST
order_item_id:307459547360919552, order_id: 307459547314782209, user_id: 20, status: INSERT_TEST
order_item_id:307459547558051840, order_id: 307459547507720193, user_id: 22, status: INSERT_TEST
order_item_id:307459547776155648, order_id: 307459547725824001, user_id: 24, status: INSERT_TEST
order_item_id:307459548015230976, order_id: 307459547935539201, user_id: 26, status: INSERT_TEST
order_item_id:307459548396912640, order_id: 307459548296249345, user_id: 28, status: INSERT_TEST
order_item_id:307459548799565824, order_id: 307459548707291137, user_id: 30, status: INSERT_TEST
order_item_id:307459549168664576, order_id: 307459549063806977, user_id: 32, status: INSERT_TEST
order_item_id:307459549500014592, order_id: 307459549445488641, user_id: 34, status: INSERT_TEST
order_item_id:307459549885890560, order_id: 307459549793615873, user_id: 36, status: INSERT_TEST
order_item_id:307459550208851968, order_id: 307459550112382977, user_id: 38, status: INSERT_TEST
order_item_id:307459550565367808, order_id: 307459550489870337, user_id: 40, status: INSERT_TEST
order_item_id:307459550972215296, order_id: 307459550884134913, user_id: 42, status: INSERT_TEST
order_item_id:307459551320342528, order_id: 307459551240650753, user_id: 44, status: INSERT_TEST
order_item_id:307459551714607104, order_id: 307459551622332417, user_id: 46, status: INSERT_TEST
order_item_id:307459552087900160, order_id: 307459552020791297, user_id: 48, status: INSERT_TEST
order_item_id:307459552456998912, order_id: 307459552385695745, user_id: 50, status: INSERT_TEST
order_item_id:307459545188270080, order_id: 307459544886280193, user_id: 1, status: INSERT_TEST
order_item_id:307459545452511232, order_id: 307459545397985281, user_id: 3, status: INSERT_TEST
order_item_id:307459545645449216, order_id: 307459545595117569, user_id: 5, status: INSERT_TEST
order_item_id:307459545863553024, order_id: 307459545813221377, user_id: 7, status: INSERT_TEST
order_item_id:307459546077462528, order_id: 307459546022936577, user_id: 9, status: INSERT_TEST
order_item_id:307459546308149248, order_id: 307459546232651777, user_id: 11, status: INSERT_TEST
order_item_id:307459546568196096, order_id: 307459546505281537, user_id: 13, status: INSERT_TEST
order_item_id:307459546798882816, order_id: 307459546714996737, user_id: 15, status: INSERT_TEST
order_item_id:307459547016986624, order_id: 307459546966654977, user_id: 17, status: INSERT_TEST
order_item_id:307459547260256256, order_id: 307459547201536001, user_id: 19, status: INSERT_TEST
order_item_id:307459547457388544, order_id: 307459547402862593, user_id: 21, status: INSERT_TEST
order_item_id:307459547667103744, order_id: 307459547608383489, user_id: 23, status: INSERT_TEST
order_item_id:307459547881013248, order_id: 307459547822292993, user_id: 25, status: INSERT_TEST
order_item_id:307459548199780352, order_id: 307459548111699969, user_id: 27, status: INSERT_TEST
order_item_id:307459548594044928, order_id: 307459548501770241, user_id: 29, status: INSERT_TEST
order_item_id:307459548996698112, order_id: 307459548900229121, user_id: 31, status: INSERT_TEST
order_item_id:307459549353213952, order_id: 307459549256744961, user_id: 33, status: INSERT_TEST
order_item_id:307459549705535488, order_id: 307459549592289281, user_id: 35, status: INSERT_TEST
order_item_id:307459550024302592, order_id: 307459549932027905, user_id: 37, status: INSERT_TEST
order_item_id:307459550410178560, order_id: 307459550317903873, user_id: 39, status: INSERT_TEST
order_item_id:307459550787665920, order_id: 307459550670225409, user_id: 41, status: INSERT_TEST
order_item_id:307459551165153280, order_id: 307459551060295681, user_id: 43, status: INSERT_TEST
order_item_id:307459551504891904, order_id: 307459551421005825, user_id: 45, status: INSERT_TEST
order_item_id:307459551920128000, order_id: 307459551823659009, user_id: 47, status: INSERT_TEST
order_item_id:307459552306003968, order_id: 307459552188563457, user_id: 49, status: INSERT_TEST

Springboot integration sharding-jdbc force hint example

I would like to ask if there is springboot integrated sharding-jdbc example of the hint strategy , I modify spring-boot-nodep-mybatis-example to modify config as follow, but reported the following error:
The error occurred while setting parameters
Cause: java.lang.ClassCastException: io.shardingsphere.core.routing.strategy.none.NoneShardingStrategy cannot be cast to io.shardingsphere.core.routing.strategy.hint.HintShardingStrategy

config:
`sharding.jdbc.datasource.names=ds_0,ds_1

sharding.jdbc.datasource.ds_0.type=org.apache.commons.dbcp.BasicDataSource
sharding.jdbc.datasource.ds_0.driver-class-name=com.mysql.jdbc.Driver
sharding.jdbc.datasource.ds_0.url=jdbc:mysql://10.1.109.125:3306/demo_ds_0
sharding.jdbc.datasource.ds_0.username=root
sharding.jdbc.datasource.ds_0.password=123456

sharding.jdbc.datasource.ds_1.type=org.apache.commons.dbcp.BasicDataSource
sharding.jdbc.datasource.ds_1.driver-class-name=com.mysql.jdbc.Driver
sharding.jdbc.datasource.ds_1.url=jdbc:mysql://10.1.109.125:3306/demo_ds_1
sharding.jdbc.datasource.ds_1.username=root
sharding.jdbc.datasource.ds_1.password=123456

sharding.jdbc.config.sharding.default-database-strategy.hint.algorithm-class-name=io.shardingsphere.example.spring.boot.mybatis.nodep.MyHintShardingAlgorithm
`
My scenario is that each library has the same data structure. I just want to divide the library according to the system similar to the enumeration, such as passing a fixed parameter then to the fixed library. There is no need to configure routing rules for each table.
I would like to ask how this is handled, thank you very much, best wishes!

Change the example code to use oracle occur exception

try to run example on oracle,I modified two files.

  1. pom.xml oracle driver

<dependency> <groupId>com.oracle.jdbc</groupId> <artifactId>ojdbc8</artifactId> <version>12.2.0.1</version> </dependency>
2. shrdingTables.xml

<bean id="demo_ds" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" /> <property name="url" value="jdbc:oracle:thin:@192.168.0.80:1521:orcl" /> <property name="username" value="dev_system" /> <property name="password" value="dev_system" /> </bean>

run ShardingOnlyWithTables.java occur Exception:

Caused by: groovy.lang.MissingPropertyException: No such property: INTERNET_USERS for class: Script776
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53)
at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:52)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:307)
at Script776.run(Script776.groovy:1)
at io.shardingsphere.core.util.InlineExpressionParser.evaluate(InlineExpressionParser.java:109)
at io.shardingsphere.core.util.InlineExpressionParser.evaluate(InlineExpressionParser.java:96)
at io.shardingsphere.core.util.InlineExpressionParser.splitAndEvaluate(InlineExpressionParser.java:74)
at io.shardingsphere.core.rule.TableRule.(TableRule.java:63)
at io.shardingsphere.core.rule.ShardingRule.createTableRuleWithDefaultDataSource(ShardingRule.java:145)
at io.shardingsphere.core.rule.ShardingRule.getTableRuleByLogicTableName(ShardingRule.java:136)
at io.shardingsphere.core.metadata.table.executor.TableMetaDataLoader.load(TableMetaDataLoader.java:64)
at io.shardingsphere.core.metadata.table.executor.TableMetaDataInitializer.loadDefaultTables(TableMetaDataInitializer.java:82)
at io.shardingsphere.core.metadata.table.executor.TableMetaDataInitializer.load(TableMetaDataInitializer.java:62)
at io.shardingsphere.core.metadata.ShardingMetaData.(ShardingMetaData.java:46)
at io.shardingsphere.core.jdbc.core.ShardingContext.init(ShardingContext.java:84)
at io.shardingsphere.core.jdbc.core.ShardingContext.(ShardingContext.java:72)
at io.shardingsphere.core.jdbc.core.datasource.ShardingDataSource.getShardingContext(ShardingDataSource.java:81)
at io.shardingsphere.core.jdbc.core.datasource.ShardingDataSource.(ShardingDataSource.java:72)
at io.shardingsphere.jdbc.spring.datasource.SpringShardingDataSource.(SpringShardingDataSource.java:39)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:142)
... 49 more

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.