报错内容
[WARN][org.springframework.web.context.support.XmlWebApplicationContext]-Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [spring/spring-mybatis.xml]: Initialization of bean failed; nested exception is java.lang.NoSuchMethodError: org.springframework.aop.framework.AopProxyUtils.getSingletonTarget(Ljava/lang/Object;)Ljava/lang/Object;
[INFO][com.alibaba.druid.pool.DruidDataSource]-{dataSource-1} closing ...
[INFO][com.alibaba.druid.pool.DruidDataSource]-{dataSource-1} closed
[ERROR][org.springframework.web.context.ContextLoader]-Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [spring/spring-mybatis.xml]: Initialization of bean failed; nested exception is java.lang.NoSuchMethodError: org.springframework.aop.framework.AopProxyUtils.getSingletonTarget(Ljava/lang/Object;)Ljava/lang/Object;
具体情况
昨天使用SSM整合Redis,发现突然一直报该错
BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource
java.lang.NoSuchMethodError: org.springframework.aop.framework.AopProxyUtils.getSingletonTarget(Ljava/lang/Object;)Ljava/lang/Object;
解决方案
NoSuchMethodError:https://blog.csdn.net/wypblog/article/details/102951861
错误原因:应用程序直接或间接依赖了同一个类的多个版本,并且在运行时执行了缺少方法的版本。
1.首先:我们先通过该路径查看是否存在该方法
从下图看到它是存在的
2.再看输出目录详情
果然问题出在应用程序直接或间接依赖了同一个类的多个版本
3.将spring版版本改为5.2.9.RELEASE(spring-data-redis对应依赖版本),删除输出目录Target,重启项目,恢复正常