整合Spring和Mybatis 中org.springframework.beans.factory.BeanCreationException错误

这两天学习strut2和spring的整合,启动服务器后总是爆粗如下错误,

org.springframework.beans.factory.BeanCreationException

Error creating bean with name 'sqlSessionFactory' defined in URL [file:/E:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/StrutsTest/WEB-INF/classes/applicationContext.xml]: 

Cause: org.apache.ibatis.builder.BuilderException: Error creating document instance.  Cause: org.xml.sax.SAXParseException:Document root element "mapper", must match DOCTYPE root "configuration".


网上有如下解答:

---------------------------------------------------------------------------------------------------------------------------------------

Document root element "mapper", must match DOCTYPE root "configuration"
后来才发现,原来是xml文件的!doctype定义写错了。


mybatis.xml和mapper.xml都用了一个doctype


原来不是这样的。




mybatis.xml:


"http://mybatis.org/dtd/mybatis-3-config.dtd">


mapper.xml


"http://mybatis.org/dtd/mybatis-3-mapper.dtd">

-----------------------------------------------------------------------------------------------------------------------------------------

applicationContext.xml 示例如下



   
    
    
    
    

    


  
        
    


     
        
        
    





    
        
        
    


userMap.xml 示例:




   


你可能感兴趣的:(JavaWeb)