我正在尝试使用SpringMVC和Spring数据实现一个应用程序。当我尝试持久化对象时,一切正常,但当我想在服务器上部署应用程序时,会出现如下异常:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory': Failed to introspect bean class [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean] for lookup method metadata: could not find class that it depends on; nested exception is java.lang.NoClassDefFoundError: javax/persistence/SharedCacheMode
pom.xml是
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-releasetrain</artifactId>
<version>Hopper-SR4</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.10.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.2.2.Final</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.12</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.12</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId> mysql-connector-java</artifactId>
<version>6.0.5</version>
</dependency>
</dependencies>
和应用上下文是
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="com.amir"/>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/amirdb"/>
<property name="username" value="root"/>
<property name="password" value="root"/>
</bean>
<jpa:repositories base-package="com.tsi"/>
<tx:annotation-driven/>
<!--<jdbc:embedded-database id="dataSource" />-->
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="packagesToScan" value="com.tsi"/>
<property name="jpaProperties">
<props>
<prop key="hibernate.hbm2ddl.auto">create</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
</props>
</property>
<property name="dataSource" ref="dataSource"/>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="generateDdl" value="true"/>
<property name="showSql" value="true"/>
</bean>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
</beans>
对于mvc,使用了另外两个SpringCongFig文件,它们是rootContext
<?xml version="1.0" encoding="UTF-8"?>
<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">
<import resource="classpath:applicationContext.xml"/>
</beans>
调度器servlet是
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<bean id="conversionService"
class="org.springframework.format.support.FormattingConversionServiceFactoryBean" />
<mvc:annotation-driven conversion-service="conversionService">
<mvc:argument-resolvers>
<bean class="org.springframework.data.web.SortHandlerMethodArgumentResolver"/>
<bean class="org.springframework.data.web.PageableHandlerMethodArgumentResolver">
<property name="maxPageSize" value="3"/>
</bean>
</mvc:argument-resolvers>
</mvc:annotation-driven>
<bean class="org.springframework.data.repository.support.DomainClassConverter">
<constructor-arg name="conversionService" ref="conversionService"/>
</bean>
<context:component-scan base-package="com.its" />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
在实体类中,我使用了importjavax。坚持。*
以启用@实体
注释。我想,也许我混合了不同的版本,并试图阅读相关文档,但我没有发现任何东西。如有任何建议,将不胜感激。
添加
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
</dependency>
到您的pom。xml
编辑:
添加
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Final</version>
</dependency>
Seam Persistence 使得受管的Beans可支持事务处理,同时提供 Seam Managed Persistence Context, a conversation scoped extended persistence context for use in CDI based applications. 使用示例 @Produces @ConversationScoped @Seam
Mobile-Persistence(A-Team Mobile Persistence Accelerator )是一个轻量级的持久性框架,可与 Oracle 移动应用框架 (MAF)一起使用。它减轻了 RESTful 服务负载,并提供了一个完整的能够在脱机模式下使用移动应用程序的持久性层。在没有网的情况下,你也可以读写数据,当再次联机时,更改后的数据可以完成同步。当与 JDeveloper 集
11. Data Persistence The modules described in this chapter support storing Python data in a persistent form on disk. The pickle and marshal modules can turn many Python data types into a stream of byt
EJP (Easier Java Persistence) 是一个功能强大但使用简便的 Java 持久层框架,主要特性有: 自动处理对象/关系的映射 自动处理关联 自动持久化跟踪
问题内容: 我正在为spring数据编写示例。这是我的spring.xml 这些是我pom.xml中的依赖项 我还没有使用过persistence.xml 。我正在关注异常 引起原因:java.lang.NoSuchMethodError:javax.persistence.spi.PersistenceUnitInfo.getValidationMode()Ljavax / persistenc
问题内容: 我正在升级jpa,hibernate,spring和jdk,以启用JPA 2.1中的新功能。但是我收到以下错误: 我已经阅读了有关此内容的其他帖子,但是它们无法解决我的计算机上的错误。例如,SJuan76对此帖子的回答建议升级到jpa2.1,但是我已将eclipse jpa项目方面设置为2.1版,并且我也将其包含在pom.xml中。单击此链接,您可以在完整的pom.xml中阅读各种库的