mybatis-spring升级导致的异常

时间:2022-07-21 05:09:48
先记录一下,已被后面排查问题

升级前pom.xml依赖信息:

<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.2.7</version>
</dependency>

只升级了mybatis-spring版本只1.3.1会报一个各种异常
Sep 13, 2018 8:47:56 PM org.apache.catalina.loader.WebappClassLoader loadClass
INFO: Illegal access: this web application instance has been stopped already.  Could not load io.netty.util.concurrent.DefaultPromise$2.  The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
java.lang.IllegalStateException
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1588)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
	at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:588)
	at io.netty.util.concurrent.DefaultPromise.setSuccess(DefaultPromise.java:398)
	at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:155)
	at java.lang.Thread.run(Thread.java:748)

Exception in thread "NettyClientWorkerThread_4" java.lang.NoClassDefFoundError: io/netty/util/concurrent/DefaultPromise$2
	at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:588)
	at io.netty.util.concurrent.DefaultPromise.setSuccess(DefaultPromise.java:398)
	at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:155)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: io.netty.util.concurrent.DefaultPromise$2
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
	... 4 more
Exception in thread "NettyClientWorkerThread_3" Exception in thread "NettyClientWorkerThread_2" java.lang.NoClassDefFoundError: io/netty/util/concurrent/DefaultPromise$2
	at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:588)
	at io.netty.util.concurrent.DefaultPromise.setSuccess(DefaultPromise.java:398)
	at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:155)
	at java.lang.Thread.run(Thread.java:748)
Exception in thread "NettyClientWorkerThread_1" java.lang.NoClassDefFoundError: io/netty/util/concurrent/DefaultPromise$2
	at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:588)
	at io.netty.util.concurrent.DefaultPromise.setSuccess(DefaultPromise.java:398)
	at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:155)
	at java.lang.Thread.run(Thread.java:748)
java.lang.NoClassDefFoundError: io/netty/util/concurrent/DefaultPromise$2
	at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:588)
	at io.netty.util.concurrent.DefaultPromise.setSuccess(DefaultPromise.java:398)
	at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:155)
	at java.lang.Thread.run(Thread.java:748)
Exception in thread "NettyClientSelector_1" java.lang.NoClassDefFoundError: io/netty/util/concurrent/DefaultPromise$2
	at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:588)
	at io.netty.util.concurrent.DefaultPromise.setSuccess(DefaultPromise.java:398)
	at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:155)
	at java.lang.Thread.run(Thread.java:748)

  

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lotteryWinRecordBiz': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.pajk.promotion.dao.WinRecordNormalDao com.pajk.promotion.biz.lottery.LotteryWinRecordBiz.winRecordNormalDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'winRecordNormalDao': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.pajk.promotion.mapper.WinRecordNormalDOMapper com.pajk.promotion.dao.WinRecordNormalDao.mapper; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'winRecordNormalDOMapper' defined in URL [jar:file:/usr/local/tomcat/webapps/promotion/WEB-INF/lib/promotion-biz-3.4.6-SNAPSHOT.jar!/com/pajk/promotion/mapper/WinRecordNormalDOMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory': : No qualifying bean of type [org.apache.ibatis.session.SqlSessionFactory] is defined: expected single matching bean but found 3: sqlSessionFactoryTddl,sqlSessionFactory,outPutSqlSessionFactory; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.apache.ibatis.session.SqlSessionFactory] is defined: expected single matching bean but found 3: sqlSessionFactoryTddl,sqlSessionFactory,outPutSqlSessionFactory
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:292) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1014) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:957) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:855) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	... 29 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.pajk.promotion.dao.WinRecordNormalDao com.pajk.promotion.biz.lottery.LotteryWinRecordBiz.winRecordNormalDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'winRecordNormalDao': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.pajk.promotion.mapper.WinRecordNormalDOMapper com.pajk.promotion.dao.WinRecordNormalDao.mapper; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'winRecordNormalDOMapper' defined in URL [jar:file:/usr/local/tomcat/webapps/promotion/WEB-INF/lib/promotion-biz-3.4.6-SNAPSHOT.jar!/com/pajk/promotion/mapper/WinRecordNormalDOMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory': : No qualifying bean of type [org.apache.ibatis.session.SqlSessionFactory] is defined: expected single matching bean but found 3: sqlSessionFactoryTddl,sqlSessionFactory,outPutSqlSessionFactory; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.apache.ibatis.session.SqlSessionFactory] is defined: expected single matching bean but found 3: sqlSessionFactoryTddl,sqlSessionFactory,outPutSqlSessionFactory
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:508) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	... 40 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'winRecordNormalDao': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.pajk.promotion.mapper.WinRecordNormalDOMapper com.pajk.promotion.dao.WinRecordNormalDao.mapper; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'winRecordNormalDOMapper' defined in URL [jar:file:/usr/local/tomcat/webapps/promotion/WEB-INF/lib/promotion-biz-3.4.6-SNAPSHOT.jar!/com/pajk/promotion/mapper/WinRecordNormalDOMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory': : No qualifying bean of type [org.apache.ibatis.session.SqlSessionFactory] is defined: expected single matching bean but found 3: sqlSessionFactoryTddl,sqlSessionFactory,outPutSqlSessionFactory; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.apache.ibatis.session.SqlSessionFactory] is defined: expected single matching bean but found 3: sqlSessionFactoryTddl,sqlSessionFactory,outPutSqlSessionFactory
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:292) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1014) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:957) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:855) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	... 42 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.pajk.promotion.mapper.WinRecordNormalDOMapper com.pajk.promotion.dao.WinRecordNormalDao.mapper; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'winRecordNormalDOMapper' defined in URL [jar:file:/usr/local/tomcat/webapps/promotion/WEB-INF/lib/promotion-biz-3.4.6-SNAPSHOT.jar!/com/pajk/promotion/mapper/WinRecordNormalDOMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory': : No qualifying bean of type [org.apache.ibatis.session.SqlSessionFactory] is defined: expected single matching bean but found 3: sqlSessionFactoryTddl,sqlSessionFactory,outPutSqlSessionFactory; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.apache.ibatis.session.SqlSessionFactory] is defined: expected single matching bean but found 3: sqlSessionFactoryTddl,sqlSessionFactory,outPutSqlSessionFactory
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:508) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	... 53 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'winRecordNormalDOMapper' defined in URL [jar:file:/usr/local/tomcat/webapps/promotion/WEB-INF/lib/promotion-biz-3.4.6-SNAPSHOT.jar!/com/pajk/promotion/mapper/WinRecordNormalDOMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory': : No qualifying bean of type [org.apache.ibatis.session.SqlSessionFactory] is defined: expected single matching bean but found 3: sqlSessionFactoryTddl,sqlSessionFactory,outPutSqlSessionFactory; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.apache.ibatis.session.SqlSessionFactory] is defined: expected single matching bean but found 3: sqlSessionFactoryTddl,sqlSessionFactory,outPutSqlSessionFactory
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1278) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1170) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1014) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:957) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:855) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	... 55 common frames omitted
Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [org.apache.ibatis.session.SqlSessionFactory] is defined: expected single matching bean but found 3: sqlSessionFactoryTddl,sqlSessionFactory,outPutSqlSessionFactory
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:967) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:855) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1263) ~[spring-beans-4.0.2.RELEASE.jar:4.0.2.RELEASE]
	... 66 common frames omitted

  

按其他项目的搭配mybatis:3.4.5, mybatis-spring 1.3.1依然还是以上的异常

网上找到一个版本对应表格

MyBatis-Spring MyBatis Spring
1.0.0 and 1.0.1 3.0.1 to 3.0.5 3.0.0 or higher
1.0.2 3.0.6 3.0.0 or higher
1.1.0 or higher 3.1.0 or higher 3.0.0 or higher
1.3.0 or higher 3.4.0 or higher 3.0.0 or higher