tap*_*toe 5 java mybatis spring-data-jpa spring-mybatis
我正在尝试将 Spring Data JPA 与 MyBatis 一起使用。由于 MyBatis 没有 Vendor Adapter,这里有什么替代方案?
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="com.abc.xyz.domain"/>
</bean>
Run Code Online (Sandbox Code Playgroud)
当我尝试初始化我的应用程序时,出现以下异常。
Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: No PersistenceProvider specified in EntityManagerFactory configuration, and chosen PersistenceUnitInfo does not specify a provider class name either
Run Code Online (Sandbox Code Playgroud)
谢谢
小智 6
Mybatis 没有实现 JPA。Mybatis 不是 ORM 框架。JPA 是 ORM 规范,由 Hibernate、Toplink、Eclipselink 实现。由于 Mybatis 不实现 JPA,所以它不属于 JPA 提供者列表。因此,您不能将 mybatis 用作 JPA 框架。Mybatis 是一个数据映射器框架,与 JPA 相比是完全不同的框架。在 JPA 和 ORM 框架中,您将对象/实体映射到相应的 sql 表,并且您处理对象而不是直接处理表,除非您使用它们的本机查询。在 mybatis 中,你直接玩 sql 数据.. 希望这可以清除 mybatis 和 JPA 之间的区别。因此,当您想要带有 spring 数据的 mybatis 时,您可以独立使用 spring 数据 mybatis 而不是 spring 数据 JPA。
| 归档时间: |
|
| 查看次数: |
23534 次 |
| 最近记录: |