一个mybatis测试启动遇到的问题

![图片说明
![图片说明
图片说明

图片说明
因为刚接触java不久 希望可以帮我解答下

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'studentDao' defined in URL [file:/C:/Users/%e6%8b%89%e7%81%af/workspace/student-A/target/classes/spring-sample-dao.xml]: 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 file [C:\Users\拉灯\workspace\student-A\target\classes\applicationContext-mybatis.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [C:\Users\拉灯\workspace\student-A\target\classes\StudentMapper.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 'Student'. Cause: java.lang.ClassNotFoundException: Cannot find class: Student
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.ld.student-A.service.impl.StudentServiceImpl] for bean with name 'studentService' defined in URL [file:/C:/Users/%e6%8b%89%e7%81%af/workspace/student-A/target/classes/spring-sample-service.xml]; nested exception is java.lang.ClassNotFoundException: com.ld.student-A.service.impl.StudentServiceImpl

10个回答

首先你看一看你的cfg.xml和映射文件有没有错,以及公共的sessionFactory

看一下你的studentDao对应的mapper中引用student类是不是全路径

![图片说明](https://img-ask.csdn.net/upload/201612/30/1483085483_79494.png)图片说明

是这个吗

首先,你得确定你studentDao所在的包配了注解扫描没有,如果你其他的Dao都可以扫描到的话,就看看你这个dao里面有没有语法和逻辑错误。
应该是没有扫描到图片说明

看看这个图片说明

basePackage value里面要有你类所在的包

有一个问题,你mapper里面已经有了增删改查了,;那么我就想问问你啥时候开始启动失败的,希望不要说你先全部写出来才启动服务器的

myBatis-config.xml 里,有配置连接数据库了吗?图片说明


<略>

<略>

parameterType="bean.Student"
resultType="bean.Student"

(之前回复的内容都没有显示出来,在回答一次)

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!