您的位置:首页 > 编程语言 > Java开发

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

2016-07-06 11:38 549 查看
mybatis和spring整合 出现如下错误:

<span style="font-size:18px;">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版本可能不配

于是查询
http://mvnrepository.com/artifact/org.mybatis/mybatis-spring/1.3.0


于是 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>


最后修改为这几个版本

正常启动
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: