mybatis和spring整合 出现如下错误:

 

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userServiceImpl':
 Injection of resource dependencies failed; 
 nested exception is org.springframework.beans.factory.BeanCreationException:
 Error creating bean with name 'userMapper' defined in file [D:\Program Files\java\workspaces\IdeaWorkspace\WebChat\target\WebChat\WEB-INF\classes\com\lindasoft\mapper\UserMapper.class]:
 Cannot resolve reference to bean 'sqlSessionFactory' while setting bean property 'sqlSessionFactory';
 nested exception is org.springframework.beans.factory.BeanCreationException: 
 Error creating bean with name 'sqlSessionFactory' defined in URL [file:/D:/Program%20Files/java/workspaces/IdeaWorkspace/WebChat/target/WebChat/WEB-INF/classes/spring/applicationContext.xml]: 
 Initialization of bean failed; nested exception is java.lang.reflect.MalformedParameterizedTypeException</span>

 没有其他详细的错误提示,感觉配置也没啥问题。卡住了好长时间,

 

 网上有提示spring 和mybatis版本可能不配

于是查询一下mybatis-spring的maven库,依赖的包的版本。

http://mvnrepository.com/artifact/org.mybatis/mybatis-spring/1.3.0

Initialization of bean failed; nested exception is java.lang.reflect.MalformedParameterizedTypeExce插图

于是 看到mybatis-spring版本1.3.0和 mybatis   3.4.0 以及spring  4.2.5.RELEASE版本搭配

 

    <!-- mybatis -->
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis</artifactId>
      <version>3.4.0</version>
    </dependency>
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis-spring</artifactId>
      <version>1.3.0</version>
    </dependency>

最后修改为这几个版本,正常启动! done!

类似问题都可以按照这个思路来解决。

如果觉得本文对你有帮助,欢迎点赞评论,欢迎关注我,我将努力创作更多更好的文章。

 

 

-----------------------------------------------------

我在参见 CSDN 1024 程序员活动(2019年10月24日结束)

如果我的博客对你有帮助,且有时间,欢迎浏览器后者微信扫码,帮我点赞支持我:

Initialization of bean failed; nested exception is java.lang.reflect.MalformedParameterizedTypeExce插图1

 

原文链接:https://blog.csdn.net/w605283073/article/details/51837527

本站声明:网站内容来源于网络,如有侵权,请联系我们,我们将及时处理。

本博客所有文章如无特别注明均为原创。
复制或转载请以超链接形式注明转自起风了,原文地址《Initialization of bean failed; nested exception is java.lang.reflect.MalformedParameterizedTypeExce
   

还没有人抢沙发呢~