IDEA關於之前還好好的 突然就各種create bean不行了的問題BeanCreationException: Error creating bean with name
如果你實在不知道怎麼回事不如按照我說的做一下
[org.springframework.web.context.support.XmlWebApplicationContext] - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘testController’: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.laozhu.service.TestService com.laozhu.controller.TestController.testService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘testService’: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.laozhu.dao.TestMapper com.laozhu.srv.imp.TestServiceImp.testMapper; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘testMapper’ defined in file [Z:\IdeaProjects\SpringMVC_test\SpringMVC_SSM\target\SpringMVC_SSM\WEB-INF\classes\com\laozhu\dao\TestMapper.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 class path resource [spring-mybatis.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: ‘file [Z:\IdeaProjects\SpringMVC_test\SpringMVC_SSM\target\SpringMVC_SSM\WEB-INF\classes\com\laozhu\mapping\UserMapper.xml]’; nested exception is org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 5; 元素型別 “result” 必須後跟屬性規範 “>” 或 “/>”。
**重點是這裡Error creating bean with name ‘testMapper’ defined in file [Z:\IdeaProjects\SpringMVC_test\SpringMVC_SSM\target\SpringMVC_SSM\WEB-INF\classes\com\laozhu\dao\TestMapper.class 這個快取沒有刪除 本地刪除掉target資料夾下的你的專案這個目錄 **