Closed slieer closed 1 year ago
22:16:25.619 INFO com.alibaba.druid.pool.DruidDataSource 722 init - {dataSource-1} inited 22:16:25.621 WARN org.springframework.beans.factory.support.AbstractBeanFactory 1490 getTypeForFactoryBean - Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'vipRenewSmsRecordMapper' defined in URL [jar:file:/opt/tomcat8/webapps.01/user/WEB-INF/lib/userpoint-model-1.0.0.RELEASE.jar!/com/xxxxx`digital/userpoint/dao/VipRenewSmsRecordMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory': Error creating bean with name 'sqlSessionFactory' defined in class path resource [spring-mybatis.xml]: Cannot resolve reference to bean 'dynamicDataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dynamicDataSource' defined in class path resource [spring-mybatis.xml]: Cannot resolve reference to bean 'dataSourceUser' while setting bean property 'targetDataSources' with key [TypedStringValue: value [userDB], target type [null]]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUser' defined in class path resource [spring-mybatis.xml]: Invocation of init method failed; nested exception is java.lang.ClassCastException: java.util.Collections$SynchronizedMap cannot be cast to java.util.IdentityHashMap; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [spring-mybatis.xml]: Cannot resolve reference to bean 'dynamicDataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dynamicDataSource' defined in class path resource [spring-mybatis.xml]: Cannot resolve reference to bean 'dataSourceUser' while setting bean property 'targetDataSources' with key [TypedStringValue: value [userDB], target type [null]]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUser' defined in class path resource [spring-mybatis.xml]: Invocation of init method failed; nested exception is java.lang.ClassCastException: java.util.Collections$SynchronizedMap cannot be cast to java.util.IdentityHashMap 22:16:25.661 INFO com.alibaba.druid.pool.DruidDataSource 722 init - {dataSource-2} inited 22:16:25.662 WARN org.springframework.beans.factory.support.AbstractBeanFactory 1490 getTypeForFactoryBean - Bean creation exception on non-lazy FactoryBean type check: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'VIPPointMapper' defined in URL [jar:file:/opt/tomcat8/webapps.01/user/WEB-INF/lib/userpoint-model-1.0.0.RELEASE.jar!/com/xxxxxdigital/userpoint/dao/VIPPointMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory': Error creating bean with name 'sqlSessionFactory' defined in class path resource [spring-mybatis.xml]: Cannot resolve reference to bean 'dynamicDataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dynamicDataSource' defined in class path resource [spring-mybatis.xml]: Cannot resolve reference to bean 'dataSourceUser' while setting bean property 'targetDataSources' with key [TypedStringValue: value [userDB], target type [null]]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUser' defined in class path resource [spring-mybatis.xml]: Invocation of init method failed; nested exception is java.lang.ClassCastException: java.util.Collections$SynchronizedMap cannot be cast to java.util.IdentityHashMap; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [spring-mybatis.xml]: Cannot resolve reference to bean 'dynamicDataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dynamicDataSource' defined in class path resource [spring-mybatis.xml]: Cannot resolve reference to bean 'dataSourceUser' while setting bean property 'targetDataSources' with key [TypedStringValue: value [userDB], target type [null]]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUser' defined in class path resource [spring-mybatis.xml]: Invocation of init method failed; nested exception is java.lang.ClassCastException: java.util.Collections$SynchronizedMap cannot be cast to java.util.IdentityHashMap
疯狂的刷上述日志, mysql 端的连接疯狂的增长, 直到mysql too many , jvm 奔溃!
init方法 , 就不应该搞无锁的编程方式。 我设置的连接数量参数,为什么会无效?
在初始化连接池时, 一定要校验一下当前该数据库共有多少个真实的连接。 最好提供控制某个数据库的最大连接数据的参数(一个业务模块一个连接池,而当多个业务对应一个数据库实例时, 更需要DB层面的最大连接数校验)。
init出错需要,还是需要调用close方法将DruidDataSource关闭。
感谢你的回复。 但是能不能在DruidDataSource, 做好校验呢? 比如发现数据库接连数, 达到一定的数量后,无论调用多少次init, 都不予分配置物理连接。 岂不更好? DruidDataSource的可靠性为什么要依赖于上层模块呢?
你好,楼主,druid 目前用哪个版本最好?
和这个有相似之外: https://github.com/alibaba/druid/issues/2423
我昨天也遇到了,采用的是如下的配置,在大量请求持续运行时,曾重启过myql, tomcat, 添加过/etc/hosts文件数据库本地域名(本地域名,可指向本地,远程db), 瞬间在mysql 端出现过近3000 client会话, 但多数是sleep状态的! 另外,要说明一下本地域名指向的数据库ip改了,也应该连新ip上的db啊. 根据下面的配置, 怎么也想不通啊。 今天在压测环境试了重显不了。
druid 1.0.20