浏览 3238 次
锁定老帖子 主题:学习 Hibernate-JPA 出错
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2009-06-02
最后修改:2009-06-02
... Caused by: java.lang.NoSuchMethodError: org.hibernate.cfg.AnnotationConfiguration.setProperty(Ljava/lang/String; Ljava/lang/String;)Lorg/hibernate/cfg/AnnotationConfiguration; at org.hibernate.ejb.Ejb3Configuration.setProperty(Ejb3Configuration.java:535) at org.hibernate.ejb.Ejb3Configuration.setDataSource(Ejb3Configuration.java:149) at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:399) at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory (HibernatePersistence.java:131) at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntity ManagerFactory(LocalContainerEntityManagerFactoryBean.java:224) at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet (AbstractEntityManagerFactoryBean.java:291) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory .invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1368) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory .initializeBean(AbstractAutowireCapableBeanFactory.java:1334) ... 39 more 相关类库(貌似没什么冲突啊): hibernate-annotations-3.4.0.GA hibernate-core-3.3.1.GA hibernate-entitymanager-3.4.0.GA 相关 jar 包: antlr-2.7.6.jar cglib.jar commons-beanutils.jar commons-chain-1.1.jar commons-collections-3.1.jar commons-configuration-1.2.jar commons-dbcp-1.2.1.jar commons-digester-1.7.jar commons-fileupload-1.2.1.jar commons-io-1.3.2.jar commons-lang-2.4.jar commons-logging-api-1.1.jar commons-logging.jar commons-pool-1.2.jar commons-validator-1.3.0.jar dom4j-1.6.1.jar ejb3-persistence.jar freemarker.jar hibernate-annotations.jar hibernate-commons-annotations.jar hibernate-core.jar hibernate-entitymanager.jar javassist-3.4.GA.jar jta-1.1.jar log4j-1.2.13.jar mysql-connector-java-5.1.7-bin.jar ognl.jar slf4j-api-1.5.6.jar slf4j-simple-1.5.6.jar spring-webmvc.jar spring.jar struts2-core.jar struts2-spring-plugin-2.1.6.jar xwork.jar applicationContext.xml <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <!-- 数据源配置 --> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"/> <property name="url" value="jdbc:mysql://localhost/test"/> <property name="username" value="user"/> <property name="password" value="user"/> </bean> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="persistenceXmlLocation" value="/WEB-INF/persistence.xml"/> <property name="persistenceUnitName" value="persistenceUnit"/> <property name="dataSource" ref="dataSource"/> </bean> <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="entityManagerFactory"/> </bean> <!-- spring 配置文件中配置 action --> <bean id="userService" class="login.DefaultUserService"> <property name="userDao" ref="userDao"/> </bean> <bean id="userDao" class="login.DefaultUserDao"> </bean> </beans> persistence.xml <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0"> <persistence-unit name="persistenceUnit" transaction-type="RESOURCE_LOCAL"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <properties> <property name="hibernate.show_sql" value="false"/> <property name="hibernate.hbm2ddl.auto" value="create"/> </properties> </persistence-unit> </persistence> 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2009-06-03
可能是配置的问题。HibernateJPA没有使用Spring中的配置。你先不要用Spring,只在persistence.xml中配置试试。
|
|
返回顶楼 | |
发表时间:2009-06-07
最后修改:2009-06-07
<script type="text/javascript" src="http://i.cdn.turner.com/cnn/.element/js/2.0/ad_head0.js"> </script> <script type="text/javascript"> if(cnnShow_setPref && (location.hostname.indexOf('.cnn.com') > -1)) { cnnSetEditionBox(); } </script> |
|
返回顶楼 | |