您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

EntityManager无法使用持久性将元素保存到数据库

EntityManager无法使用持久性将元素保存到数据库

要在您的Spring上下文中启用@Transactional,您应该具有以下内容

适合您的Spring版本:

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

启用注释:

<tx:annotation-driven />

声明您的事务管理器注入实体管理器:

<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
其他 2022/1/1 18:13:38 有734人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶