SSH integration project, using the annotated way, unexpectedly still have such a problem!!

Source: Internet
Author: User

In the Applicationcontext.xml file, information about hibernate is configured, where Sessionfactory is

<bean id= "Sessionfactory"         class= " Org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean ">         <property name= "DataSource" >             <ref bean= "DataSource"  />         </property>        <property name= " Hibernateproperties ">            <props>                 <prop  key= "Hibernate.dialect" >                     org.hibernate.dialect.Oracle9Dialect                 </prop>            </props>         </property>         <property name= "Packagestoscan" >             <list>                 <value>cn.jbit.pb.tcjc034.shop.entity</value>             </list>        </property>     </bean>

But if that's the case

<bean id= "Sessionfactory"         class= " Org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean ">         <property name= "DataSource" >             <ref bean= "DataSource"  />         </property>        <property name= " Hibernateproperties ">            <props>                 <prop  key= "Hibernate.dialect" >                     org.hibernate.dialect.Oracle9Dialect                 </prop>            </props>         </property>         <property name= "Packagestoscan" >             <list>                 <value>                     cn.jbit.pb.tcjc034.shop.entity                 </value>             </list>        </property>     </bean>

The

will not find the entity, the exception information is as follows:

    org.hibernate.MappingException: Unknown entity:  cn.jbit.pb.tcjc034.shop.entity.user    at  Org.hibernate.impl.SessionFactoryImpl.getEntityPersister (sessionfactoryimpl.java:628)      At org.hibernate.event.def.defaultloadeventlistener.onload (defaultloadeventlistener.java:91)      at org.hibernate.impl.sessionimpl.fireload (sessionimpl.java:906)     at  org.hibernate.impl.sessionimpl.get (sessionimpl.java:843)     at  Org.hibernate.impl.SessionImpl.get (sessionimpl.java:836)     at  Cn.jbit.pb.tcjc034.tuzki.base.dao.impl.PageBaseDaoImpl.queryEntityById (pagebasedaoimpl.java:42)      at cn.jbit.pb.tcjc034.shop.user.biz.impl.userbizimpl.queryuserbyid (UserBizImpl.java:40)   &NBSP;&NBSP;&NBSP;AT&NBSP;SUN.REFLECT.NATIVEMETHODACCESSORIMPL.INVOKE0 (Native method)      at Sun.reflect.NativeMethodAccessorImpl.invoke (nativemethodaccessorimpl.java:39)     at  Sun.reflect.DelegatingMethodAccessorImpl.invoke (delegatingmethodaccessorimpl.java:25)      At java.lang.reflect.method.invoke (method.java:597)     at  Org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection (aoputils.java:307)      at org.springframework.aop.framework.reflectivemethodinvocation.invokejoinpoint ( reflectivemethodinvocation.java:182)     at  Org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (reflectivemethodinvocation.java:149)     at org.springframework.transaction.interceptor.transactioninterceptor.invoke ( transactioninterceptor.java:106)     at  Org.springframework.aop.framework.ReflectiveMethodInvocation.proceed (reflectivemethodinvocation.java:171)     at org.springframeWork.aop.interceptor.ExposeInvocationInterceptor.invoke (exposeinvocationinterceptor.java:89)      at org.springframework.aop.framework.reflectivemethodinvocation.proceed ( reflectivemethodinvocation.java:171)     at  Org.springframework.aop.framework.JdkDynamicAopProxy.invoke (jdkdynamicaopproxy.java:204)      at com.sun.proxy. $Proxy 7.queryUserById (Unknown source)     at  Cn.jbit.pb.tcjc034.shop.test.UserTest.test (usertest.java:22)     at  SUN.REFLECT.NATIVEMETHODACCESSORIMPL.INVOKE0 (Native method)     at  Sun.reflect.NativeMethodAccessorImpl.invoke (nativemethodaccessorimpl.java:39)     at  Sun.reflect.DelegatingMethodAccessorImpl.invoke (delegatingmethodaccessorimpl.java:25)      At java.lang.reflect.method.invoke (method.java:597)     at  Org.junit.runners.model.FrameworkMethOd$1.runreflectivecall (frameworkmethod.java:44)     at  Org.junit.internal.runners.model.ReflectiveCallable.run (reflectivecallable.java:15)     at  org.junit.runners.model.frameworkmethod.invokeexplosively (frameworkmethod.java:41)      at org.junit.internal.runners.statements.invokemethod.evaluate (invokemethod.java:20)      at org.junit.internal.runners.statements.runbefores.evaluate (RunBefores.java:28)      at org.junit.internal.runners.statements.runafters.evaluate (RunAfters.java:31)      at org.junit.runners.blockjunit4classrunner.runchild (blockjunit4classrunner.java:73)      at org.junit.runners.blockjunit4classrunner.runchild (BlockJUnit4ClassRunner.java:46)     at org.junit.runners.parentrunner.runchildren (parentrunner.java:180)      at org.junit.runners.parentrunner.access$000 (parentrunner.java:41)     at org.junit.runners.parentrunner$1.evaluate ( parentrunner.java:173)     at  Org.junit.internal.runners.statements.RunBefores.evaluate (runbefores.java:28)     at  Org.junit.internal.runners.statements.RunAfters.evaluate (runafters.java:31)     at  Org.junit.runners.ParentRunner.run (parentrunner.java:220)     at  Org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run (junit4testreference.java:46)      at org.eclipse.jdt.internal.junit.runner.testexecution.run (testexecution.java:38)      at org.eclipse.jdt.internal.junit.runner.remotetestrunner.runtests (RemoteTestRunner.java:467)      at org.eclipse.jdt.internal.junit.runner.remotetestrunner.runtests ( remotetestrunner.java:683)     at  Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run (Remotetestrunner.java:390)     at org.eclipse.jdt.internal.junit.runner.remotetestrunner.main ( remotetestrunner.java:197)

Depressed ah .....

SSH integration project, using the annotated way, unexpectedly still have such a problem!!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.