Comven opened a new issue #15831:
URL: https://github.com/apache/shardingsphere/issues/15831
version:shardingsphere-jdbc-core-spring-boot-starter-5.1.0
Upgrade shardingsphere from 5.0.0 to 5.1.0,Throw the following exception:
```
org.springframework.beans.factory.UnsatisfiedDependencyException: Error
creating bean with name 'testController': Unsatisfied dependency expressed
through field 'orderInfoDao'; nested exception is
org.springframework.beans.factory.UnsatisfiedDependencyException: Error
creating bean with name 'orderInfoDao' defined in file
[D:\WorkPlace\idea\shardingsphere-jdbc\target\classes\org\demo\shardingsphere\jdbc\mapper\OrderInfoDao.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 'shardingSphereDataSource' defined in class path
resource
[org/apache/shardingsphere/spring/boot/ShardingSphereAutoConfiguration.class]:
Bean instantiation via factory method failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to instantiate
[javax.sql.DataSource]: Factory method 'shardingSphereDataSource' threw
exception; nested exception is java.lang.NullPointerException
at
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:659)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:639)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1431)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
~[spring-context-5.3.13.jar:5.3.13]
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
~[spring-context-5.3.13.jar:5.3.13]
at
org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
~[spring-boot-2.5.7.jar:2.5.7]
at
org.springframework.boot.SpringApplication.refresh(SpringApplication.java:765)
[spring-boot-2.5.7.jar:2.5.7]
at
org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:445)
[spring-boot-2.5.7.jar:2.5.7]
at
org.springframework.boot.SpringApplication.run(SpringApplication.java:338)
[spring-boot-2.5.7.jar:2.5.7]
at
org.springframework.boot.SpringApplication.run(SpringApplication.java:1354)
[spring-boot-2.5.7.jar:2.5.7]
at
org.springframework.boot.SpringApplication.run(SpringApplication.java:1343)
[spring-boot-2.5.7.jar:2.5.7]
at org.demo.shardingsphere.jdbc.JdbcApp.main(JdbcApp.java:15)
[classes/:na]
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'orderInfoDao' defined in file
[D:\WorkPlace\idea\shardingsphere-jdbc\target\classes\org\demo\shardingsphere\jdbc\mapper\OrderInfoDao.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 'shardingSphereDataSource' defined in class path
resource
[org/apache/shardingsphere/spring/boot/ShardingSphereAutoConfiguration.class]:
Bean instantiation via factory method failed; nested exception is
org.springframework.beans.BeanInstantiat
ionException: Failed to instantiate [javax.sql.DataSource]: Factory method
'shardingSphereDataSource' threw exception; nested exception is
java.lang.NullPointerException
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1534)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1417)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1380)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1300)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:656)
~[spring-beans-5.3.13.jar:5.3.13]
... 20 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 'shardingSphereDataSource' defined in class path
resource
[org/apache/shardingsphere/spring/boot/ShardingSphereAutoConfiguration.class]:
Bean instantiation via factory method failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to instantiate
[javax.sql.DataSource]: Factory method 'shardingSphereDataSource' threw
exception; nested exception is java.lang.NullPointerException
at
org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:541)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1380)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1300)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1519)
~[spring-beans-5.3.13.jar:5.3.13]
... 31 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'shardingSphereDataSource' defined in class path
resource
[org/apache/shardingsphere/spring/boot/ShardingSphereAutoConfiguration.class]:
Bean instantiation via factory method failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to instantiate
[javax.sql.DataSource]: Factory method 'shardingSphereDataSource' threw
exception; nested exception is java.lang.NullPointerException
at
org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1380)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1300)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791)
~[spring-beans-5.3.13.jar:5.3.13]
... 44 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to
instantiate [javax.sql.DataSource]: Factory method 'shardingSphereDataSource'
threw exception; nested exception is java.lang.NullPointerException
at
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
~[spring-beans-5.3.13.jar:5.3.13]
at
org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
~[spring-beans-5.3.13.jar:5.3.13]
... 58 common frames omitted
Caused by: java.lang.NullPointerException: null
at
org.apache.shardingsphere.readwritesplitting.checker.AbstractReadwriteSplittingRuleConfigurationChecker.lambda$checkDataSources$0(AbstractReadwriteSplittingRuleConfigurationChecker.java:41)
~[shardingsphere-readwrite-splitting-core-5.1.0.jar:5.1.0]
at java.lang.Iterable.forEach(Iterable.java:75) ~[na:1.8.0_181]
at
org.apache.shardingsphere.readwritesplitting.checker.AbstractReadwriteSplittingRuleConfigurationChecker.checkDataSources(AbstractReadwriteSplittingRuleConfigurationChecker.java:40)
~[shardingsphere-readwrite-splitting-core-5.1.0.jar:5.1.0]
at
org.apache.shardingsphere.readwritesplitting.checker.AbstractReadwriteSplittingRuleConfigurationChecker.check(AbstractReadwriteSplittingRuleConfigurationChecker.java:36)
~[shardingsphere-readwrite-splitting-core-5.1.0.jar:5.1.0]
at
org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource.lambda$null$0(ShardingSphereDataSource.java:69)
~[shardingsphere-jdbc-core-5.1.0.jar:5.1.0]
at java.util.Optional.ifPresent(Optional.java:159) ~[na:1.8.0_181]
at
org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource.lambda$checkRuleConfiguration$1(ShardingSphereDataSource.java:69)
~[shardingsphere-jdbc-core-5.1.0.jar:5.1.0]
at java.util.ArrayList.forEach(ArrayList.java:1257) ~[na:1.8.0_181]
at
org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource.checkRuleConfiguration(ShardingSphereDataSource.java:69)
~[shardingsphere-jdbc-core-5.1.0.jar:5.1.0]
at
org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource.<init>(ShardingSphereDataSource.java:62)
~[shardingsphere-jdbc-core-5.1.0.jar:5.1.0]
at
org.apache.shardingsphere.driver.api.ShardingSphereDataSourceFactory.createDataSource(ShardingSphereDataSourceFactory.java:77)
~[shardingsphere-jdbc-core-5.1.0.jar:5.1.0]
at
org.apache.shardingsphere.spring.boot.ShardingSphereAutoConfiguration.shardingSphereDataSource(ShardingSphereAutoConfiguration.java:93)
~[shardingsphere-jdbc-core-spring-boot-starter-5.1.0.jar:5.1.0]
at
org.apache.shardingsphere.spring.boot.ShardingSphereAutoConfiguration$$EnhancerBySpringCGLIB$$408e03f3.CGLIB$shardingSphereDataSource$1(<generated>)
~[shardingsphere-jdbc-core-spring-boot-starter-5.1.0.jar:5.1.0]
at
org.apache.shardingsphere.spring.boot.ShardingSphereAutoConfiguration$$EnhancerBySpringCGLIB$$408e03f3$$FastClassBySpringCGLIB$$c618357e.invoke(<generated>)
~[shardingsphere-jdbc-core-spring-boot-starter-5.1.0.jar:5.1.0]
at
org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
~[spring-core-5.3.13.jar:5.3.13]
at
org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331)
~[spring-context-5.3.13.jar:5.3.13]
at
org.apache.shardingsphere.spring.boot.ShardingSphereAutoConfiguration$$EnhancerBySpringCGLIB$$408e03f3.shardingSphereDataSource(<generated>)
~[shardingsphere-jdbc-core-spring-boot-starter-5.1.0.jar:5.1.0]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
~[na:1.8.0_181]
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
~[na:1.8.0_181]
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
~[na:1.8.0_181]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
at
org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
~[spring-beans-5.3.13.jar:5.3.13]
... 59 common frames omitted
```
Downgrade from 5.1.0 to 5.0.0, and the program runs normally. The
configuration information is as follows:
```
spring.shardingsphere.props.sql-show=true
spring.shardingsphere.datasource.names=db1master,db1slaver
spring.shardingsphere.datasource.db1master.jdbc-url=jdbc:mysql://127.0.0.1:3306/db1_master?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false&reconnect=true&serverTimezone=Asia/Shanghai
spring.shardingsphere.datasource.db1master.username=root
spring.shardingsphere.datasource.db1master.password=123456
spring.shardingsphere.datasource.db1master.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.db1master.driver-class-name=com.mysql.cj.jdbc.Driver
spring.shardingsphere.datasource.db1slaver.jdbc-url=jdbc:mysql://127.0.0.1:3306/db1_slaver?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false&reconnect=true&serverTimezone=Asia/Shanghai
spring.shardingsphere.datasource.db1slaver.username=root
spring.shardingsphere.datasource.db1slaver.password=123456
spring.shardingsphere.datasource.db1slaver.readOnly=true
spring.shardingsphere.datasource.db1slaver.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.db1slaver.driver-class-name=com.mysql.cj.jdbc.Driver
spring.shardingsphere.rules.sharding.tables.order_info.actual-data-nodes=dbrwone.order_info_20210$->{1..9},dbrwone.order_info_2021$->{10..12}
spring.shardingsphere.rules.sharding.tables.order_info.table-strategy.standard.sharding-column=add_time
spring.shardingsphere.rules.sharding.tables.order_info.table-strategy.standard.sharding-algorithm-name=tb-month-sharding
# IntervalShardingAlgorithm
spring.shardingsphere.rules.sharding.sharding-algorithms.tb-month-sharding.type=interval
spring.shardingsphere.rules.sharding.sharding-algorithms.tb-month-sharding.props.datetime-interval-amount=1
spring.shardingsphere.rules.sharding.sharding-algorithms.tb-month-sharding.props.datetime-interval-unit=Months
spring.shardingsphere.rules.sharding.sharding-algorithms.tb-month-sharding.props.sharding-suffix-pattern=yyyyMM
spring.shardingsphere.rules.sharding.sharding-algorithms.tb-month-sharding.props.datetime-pattern=yyyy-MM-dd
HH:mm:ss
spring.shardingsphere.rules.sharding.sharding-algorithms.tb-month-sharding.props.datetime-lower=2021-06-01
00:00:00
spring.shardingsphere.rules.sharding.sharding-algorithms.tb-month-sharding.props.datetime-upper=2022-12-31
23:59:59
#sharding_one read write config
spring.shardingsphere.rules.readwrite-splitting.dataSources.dbrwone.write-data-source-name=db1master
spring.shardingsphere.rules.readwrite-splitting.dataSources.dbrwone.read-data-source-names=db1slaver
```
Does anyone know what caused 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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]