java.lang.reflect.MalformedParameterizedTypeException 的解决办法
原文链接: https://blog.csdn.net/4color/article/details/70139029
近期在开发项目时用到了spring mvc 和mybatis时运行出现如下错误:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sqlSessionFactory’ defined in class path resource [config/spring-database.xml]: Initialization of bean failed; nested exception is java.lang.reflect.MalformedParameterizedTypeException
网上搜了一圈都说是springmvc和mybatis的版本冲突,改过之后,还是一样。
今天突然想到了调试一下他们的源码
新到断点到 MalformedParameterizedTypeException 中
运行后发现具体的错误是 org.apache,ibatis的问题,查了一下,ibatis早改为mybatis了,然后去掉这个引用就正常了。
删除poe.xml里面的这个依赖就解决了:
<dependency>
<groupId>org.apache.ibatis</groupId>
<artifactId>ibatis-core</artifactId>
<version>3.0</version>
</dependency>
org.apache.ibatis ibatis-core 3.0 在我刚接触JAVA的那个年代,ibatis还是叫ibatis,没想到现在已经改名了。要解决这种问题,最好是调试spring源代码。所以要学习怎么调试各种框架源代码。
其它解决问题的办法在于找到真正的 问题所在。光看表面的提示其是查不出问题的