java.lang.NoSuchMethodError: org.hibernate.cfg.Configuration.addAnnotatedClass 10
最近在看马士兵的spring,看到spring和hibernate整合,这边出了问题,麻烦哪位大牛帮我看下,谢谢...org.springframework.beans....
最近在看马士兵的spring,看到spring和hibernate整合,这边出了问题,麻烦哪位大牛帮我看下,谢谢...
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [bean.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.hibernate.cfg.Configuration.addAnnotatedClass(Ljava/lang/Class;)Lorg/hibernate/cfg/Configuration;
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean
Caused by: java.lang.NoSuchMethodError: org.hibernate.cfg.Configuration.addAnnotatedClass(Ljava/lang/Class;)Lorg/hibernate/cfg/Configuration;
at org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean.postProcessMappings(AnnotationSessionFactoryBean.java:158)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:657)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSe
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="annotatedClasses">
<list>
<value>com.pm.model.User</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean> 展开
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [bean.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.hibernate.cfg.Configuration.addAnnotatedClass(Ljava/lang/Class;)Lorg/hibernate/cfg/Configuration;
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean
Caused by: java.lang.NoSuchMethodError: org.hibernate.cfg.Configuration.addAnnotatedClass(Ljava/lang/Class;)Lorg/hibernate/cfg/Configuration;
at org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean.postProcessMappings(AnnotationSessionFactoryBean.java:158)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:657)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSe
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="annotatedClasses">
<list>
<value>com.pm.model.User</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean> 展开
4个回答
展开全部
你的herbinate包换成最新版本,herbinate3.jar里面没有addAnnotatedClass方法,而herbinate4.0.0里面有该方法
public Configuration addAnnotatedClass(Class annotatedClass)
{
XClass xClass = this.reflectionManager.toXClass(annotatedClass);
this.metadataSourceQueue.add(xClass);
return this;
},你要是要的话我有这个包,可以发给你
public Configuration addAnnotatedClass(Class annotatedClass)
{
XClass xClass = this.reflectionManager.toXClass(annotatedClass);
this.metadataSourceQueue.add(xClass);
return this;
},你要是要的话我有这个包,可以发给你
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
从异常的信息来看是报找不到匹配的方法,无法通过注解,配置信息错误,你看看是不是注解出现了问题,名字错了,或者引用类名路径等等
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我也遇到相同的问题了 ,解决了没?给点建议,谢谢!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询