**
springBoot整合mybatis时报的错
**
声明:用来记录错误信息的。有哪里不正确的欢迎指正-o(▽)o-
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘userController’: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘userService’: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘userMapper’ defined in file [D:\PC\idea\sbmybatis\target\classes\com\smbms\dao\UserMapper.class]: Unsatisfied dependency expressed through bean property ‘sqlSessionFactory’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sqlSessionFactory’ defined in class path resource [org.apache.ibatis.session.SqlSessionFactory]: Factory method ‘sqlSessionFactory’ threw exception; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: ‘file [D:\PC\idea\sbmybatis\target\classes\mapper\UserMapper.xml]’; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias ‘User’. Cause: java.lang.ClassNotFoundException: Cannot find class: User
我解决的方式:
在UserMapper.xml中的查询语句:
select * from smbms_user
因没设别名,所以resultType=“com.smbms.pojo.User”
要写完全的包名。
我遇到此错误是因没写包名,只写了实体类名。