2017-10-09 39 views
0

我刚开始学习Spring Data JPA,我在本地主机连接到mysql并且能够保存一条记录,但我无法理解为什么它在工作,如果我没有给属性文件中的方言属性,并且是休眠弹簧的默认实现数据而不是ibatis或Eclispe链接,因为在我的pom.xml中,我只是添加了spring-data-jpa的依赖关系,并且从未提及要使用哪种JPA实现。Spring Data JPA在内部使用Hibernate和为什么我的应用程序正在工作如果我不提供方言属性?

application.properties

spring.jpa.hibernate.ddl-auto=create 
spring.jpa.properties.hibernate. 
spring.datasource.url=jdbc:mysql://localhost:3306/initsoftware 
spring.datasource.driver-class-name=com.mysql.jdbc.Driver 
spring.datasource.username=ppppppp 
spring.datasource.password=xxxxxxx 
logging.level.root=DEBUG 
spring.jpa.show-sql=true 

回答

0

既然你有一个application.properties我假设你正在使用Spring启动并不仅仅是春天数据JPA。

为了在Spring Boot中使用JPA,您通常会将spring-boot-starter-data-jpa添加到您的依赖项中。这确实带有Hibernate,因为你可以看到when you inspect the dependencies

Spring数据JPA本身没有带有JPA实现。你必须补充说。

iBatis不是JPA实现。

如果上述假设与您的情况不符,则可以使用maven dependency plugin来检查您的(临时)依赖关系。以下是一个很好的起点。

mvn dependency:tree -Dverbose 

如果您使用不同的构建工具,它可能具有类似的功能。

相关问题