java Spring Data JPA 和 MyBatis

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33652936/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 21:56:43  来源:igfitidea点击:

Spring Data JPA & MyBatis

javaspring-data-jpamybatisspring-mybatis

提问by srini

I am trying to use Spring Data JPA with MyBatis. Since there isnt a Vendor Adapter for MyBatis, what is the alternative here?

我正在尝试将 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>

I am getting the below exception when I tried to initialize my application.

当我尝试初始化我的应用程序时,出现以下异常。

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

Thanks

谢谢

回答by Leonardo Saracini

Spring Data MyBatis

Spring Data MyBatis

If you would notlike to use a JPA implementation like Spring-Data-JPAmodule, but you like use Spring-Datayou can find Spring-Data-Mybatisa useful project.

如果您喜欢使用像Spring-Data-JPA模块这样的 JPA 实现,但您喜欢使用Spring-Data,那么您会发现 Spring-Data-Mybatis是一个有用的项目。

I know that this is not precise answer to your question but I hope that this answer can be interesting.

我知道这不是您问题的准确答案,但我希望这个答案很有趣。

回答by Dimitri Kopriwa

Spring-Data-Mybatis Hatunet version

Spring-Data-Mybatis Hatunet版

I am using this project: https://github.com/hatunet/spring-data-mybatis

我正在使用这个项目:https: //github.com/hatunet/spring-data-mybatis

It fit very well with spring-data-mybatis and it have also the paginated repository.

它非常适合 spring-data-mybatis 并且它还有分页存储库。

Work very well on production project.

在生产项目上工作得很好。

回答by stormning

Why not try spring-data-jpa-extra

为什么不试试spring-data-jpa-extra

It provide a dynamic query solution for spring-data-jpa like mybatis, but much easier than mybatis.

它提供了类似mybatis 的spring-data-jpa 的动态查询解决方案,但比mybatis 容易得多。

I think you would like it : )

我想你会喜欢的 :)