问题描述
错误:Exceptioninthread"main"org.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'sessionFactory'definedinclasspathresource[applicationContext.xml]:Invocationofinitmethodfailed;nestedexceptionisorg.hibernate.MappingException:Unabletodetermineentitynameatorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)atjava.security.AccessController.doPrivileged(NativeMethod)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)atorg.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)atorg.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)atorg.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)atorg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)atorg.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)atorg.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)atorg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)atorg.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)atorg.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)atcom.wzm.test.SsTest.main(SsTest.java:13)Causedby:org.hibernate.MappingException:Unabletodetermineentitynameatorg.hibernate.cfg.HbmBinder.bindClass(HbmBinder.java:541)atorg.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:293)atorg.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:166)atorg.hibernate.cfg.Configuration.add(Configuration.java:702)atorg.hibernate.cfg.Configuration.addInputStream(Configuration.java:537)atorg.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:631)atorg.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)...15moreSpring的配置文件,applicationContext.xml:<?xmlversion="1.0"encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xmlns:tx="http://www.springframework.org/schema/tx"xmlns:p="http://www.springframework.org/schema/p"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-2.5.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-2.5.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-2.5.xsd"><beanid="dataSource"class="com.mchange.v2.c3p0.ComboPooledDataSource"destroy-method="close"><propertyname="driverClass"value="oracle.jdbc.driver.OracleDriver"/><propertyname="jdbcUrl"value="jdbc:oracle:thin:@localhost:1521:orcl"/><propertyname="user"value="admin"/><propertyname="password"value="admin"/><propertyname="maxPoolSize"value="20"/><propertyname="minPoolSize"value="1"/><propertyname="initialPoolSize"value="1"/><propertyname="maxIdleTime"value="20"/></bean><beanid="sessionFactory"class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"><propertyname="dataSource"ref="dataSource"/><propertyname="mappingResources"><list><value>com/wzm/bean/User.hbm.xml</value></list></property><propertyname="hibernateProperties"><value>hibernate.dialect=org.hibernate.dialect.Oracle10gDialecthibernate.hbm2ddl.auto=updatehibernate.show_sql=true</value></property></bean><beanid="transactionManager"class="org.springframework.orm.hibernate3.HibernateTransactionManager"><propertyname="sessionFactory"ref="sessionFactory"/></bean><tx:annotation-driventransaction-manager="transactionManager"/><beanid="service"class="com.wzm.service.UserService"><propertyname="sessionFactory"ref="sessionFactory"/></bean></beans>业务类已继承HibernateDaoSupport:publicclassUserServiceextendsHibernateDaoSupport{publicvoidadd(Useruser){this.getHibernateTemplate().save(user);}}
解决方案
解决方案二:
什么玩意真心没看懂啊
解决方案三:
你没有配置User吧
解决方案四:
org.hibernate.MappingException:Unabletodetermineentityname实体类问题
解决方案五:
映射文件没有配置正确
解决方案六:
检查配置文件,这个问题基本上都是配置文件的问题
解决方案七:
配置文件问题
解决方案八:
Unabletodetermineentityname
解决方案九:
未能找到实体名称
解决方案十:
Unabletodetermineentityname无法确定你这个实体类实体类注入错误