解决InvalidMappingException: Could not parse mapping document from resource问题的办法。

          如果您出现如下问题:
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path  resource      [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.InvalidMappingException: Could  not parse mapping document from resource bean/WaterInfo.hbm.xml
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:45
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:83)at daoImpl.Test.main(Test.java:14)

Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from resource bean/WaterInfo.hbm.xml

at org.hibernate.cfg.Configuration.addResource(Configuration.java:588)
at org.hibernate.cfg.AnnotationConfiguration.addResource(AnnotationConfiguration.java:912)
at org.hibernate.cfg.AnnotationConfiguration.parseMappingElement(AnnotationConfiguration.java:617)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1574)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1553)
at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:1002)
at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:69)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1527)
at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:990)
at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:69)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1462)
at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:978)
at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:69)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:642)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)

您可以到这:http://forum.spring.io/forum/spring-projects/data/36297-org-hibernate-invalidmappingexception-could-not-parse-mapping-document-from-invalid看看。

你可能感兴趣的:(Java)