iGitHubJ opened a new issue #5697:
URL: https://github.com/apache/shardingsphere/issues/5697


   ## Question
   It happens"IllegalArgumentException: Property 'sqlSessionFactory' or 
'sqlSessionTemplate' are required", when I use sharding orchestration .
   env:springboot2.2.5
   version:sharding-jdbc 4.0.1sharding-jdbc-orchestration 4.0.1
   The configuration of the datasource is as follows:
   
   > spring.shardingsphere.props.sql.show=true
   > 
   > spring.shardingsphere.datasource.names=ds0,ds1
   > 
   > 
spring.shardingsphere.datasource.ds0.type=com.zaxxer.hikari.HikariDataSource
   > 
spring.shardingsphere.datasource.ds0.driver-class-name=com.mysql.cj.jdbc.Driver
   > 
spring.shardingsphere.datasource.ds0.jdbc-url=jdbc:mysql://localhost:3306/tenant_db_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
   > spring.shardingsphere.datasource.ds0.username=root
   > spring.shardingsphere.datasource.ds0.password=123456
   > 
   > 
spring.shardingsphere.datasource.ds1.type=com.zaxxer.hikari.HikariDataSource
   > 
spring.shardingsphere.datasource.ds1.driver-class-name=com.mysql.cj.jdbc.Driver
   > 
spring.shardingsphere.datasource.ds1.jdbc-url=jdbc:mysql://localhost:3306/tenant_db_2?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
   > spring.shardingsphere.datasource.ds1.username=root
   > spring.shardingsphere.datasource.ds1.password=123456
   > 
   > 
   > 
spring.shardingsphere.sharding.default-database-strategy.inline.sharding-column=tenant_id
   > 
spring.shardingsphere.sharding.default-database-strategy.inline.algorithm-expression=ds$->{tenant_id
 - 1}
   > 
   > 
spring.shardingsphere.sharding.tables.t_emp.actual-data-nodes=ds$->{0..1}.t_emp
   > spring.shardingsphere.sharding.tables.t_emp.key-generator.column=emp_id
   > spring.shardingsphere.sharding.tables.t_emp.key-generator.type=SNOWFLAKE
   > 
spring.shardingsphere.sharding.tables.t_emp.key-generator.props.worker.id=123
   > 
   > spring.shardingsphere.orchestration.name=demo_spring_boot_ds_sharding
   > spring.shardingsphere.orchestration.overwrite=false
   > spring.shardingsphere.orchestration.registry.server-lists=localhost:2181
   > 
spring.shardingsphere.orchestration.registry.namespace=orchestration_spring_boot_ns
   > spring.shardingsphere.orchestration.registry.type=zookeeper
   
   程序已将数据源信息写入到zookeeper中,但是出现了错误
   错误堆栈如下:
   
   > Caused by: org.springframework.beans.factory.BeanCreationException: Error 
creating bean with name 'empDao' defined in file 
[E:\workspaces\java\trace-code\trace-code-web\trace-code-admin\target\classes\com\ysg\dao\EmpDao.class]:
 Invocation of init method failed; nested exception is 
java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 
'sqlSessionTemplate' are required
   >    at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796)
 ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
   >    at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595)
 ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
   >    at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
 ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
   >    at 
org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
 ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
   >    at 
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
 ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
   >    at 
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
 ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
   >    at 
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
 ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
   >    at 
org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
 ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
   >    at 
org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1287)
 ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
   >    at 
org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1207)
 ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
   >    at 
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640)
 ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
   >    ... 19 common frames omitted
   > Caused by: java.lang.IllegalArgumentException: Property 
'sqlSessionFactory' or 'sqlSessionTemplate' are required
   >    at org.springframework.util.Assert.notNull(Assert.java:198) 
~[spring-core-5.2.4.RELEASE.jar:5.2.4.RELEASE]
   >    at 
org.mybatis.spring.support.SqlSessionDaoSupport.checkDaoConfig(SqlSessionDaoSupport.java:122)
 ~[mybatis-spring-2.0.4.jar:2.0.4]
   >    at 
org.mybatis.spring.mapper.MapperFactoryBean.checkDaoConfig(MapperFactoryBean.java:73)
 ~[mybatis-spring-2.0.4.jar:2.0.4]
   >    at 
org.springframework.dao.support.DaoSupport.afterPropertiesSet(DaoSupport.java:44)
 ~[spring-tx-5.2.4.RELEASE.jar:5.2.4.RELEASE]
   >    at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1855)
 ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
   >    at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1792)
 ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE]
   >    ... 29 common frames omitted
   
   **For English only**, other languages will not accept.
   
   Before asking a question, make sure you have:
   
   - Googled your question.
   - Searched open and closed [GitHub 
issues](https://github.com/apache/shardingsphere/issues).
   - Read documentation: [ShardingSphere 
Doc](https://shardingsphere.apache.org/document/current/en/overview).
   
   Please pay attention on issues you submitted, because we maybe need more 
details. 
   If no response **more than 7 days** and we cannot reproduce it on current 
information, we will **close it**.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to