第一次碰见它,我首先在网上找了好多类似的博客,但最终都无果.为了解决它我用了一整天的时间,最后选择放弃它.到了第二天我新建了另一个项目,然后我复用了一些上个项目(那个bug所在的项目)的代码,那些代码本身我感觉肯定没有问题,我开始配置文件,新建pojo,dao,映射文件等,建好之后,写了一个小demo开始测试,测试之前我整理一下代码格式,我无意间看到有一行代码里多了一个空格:
<setting name="logImpl" value="LOG4J "/>
我把这个空格删了之后,开始测试,很顺利没有bug,我想到上个项目是不是就因为这个空格,于是我把空格加上,报的错误信息和上次一样.
于是我悟了,
总结:再遇到这样的报错,就看配置文件代码是否规范还有是不是该加注解的没加等等.
最后附上报错详情:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'teacherDao' defined in file
[D:\MavenWeb\target\classes\com\example\model\dao\TeacherDao.clas
s]: 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 class path
resource [applicationContent.xml]: Invocation of init method failed;
nested exception is org.springframework.core.NestedIOException:
Failed to parse config resource: class path resource [mybatis-config.xml]; nested exception is
org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper
Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error
resolving class. Cause: org.apache.ibatis.type.TypeException: Could not
resolve type alias 'LOG4J '. Cause: java.lang.ClassNotFoundException:
Cannot find class: LOG4J