本文介绍了SpringBoot 1.3.0支持hibernate 5?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对SpringBoot对Hibernate5的支持(1.3.0)有点困惑。该引用列出了对hibernate 4.3.11.Final的依赖关系,但它也列出了对SpringFramework 4.2.3的依赖关系,其中包括对Hibernate5的支持。

I'm a little confused about SpringBoot's (1.3.0) support of Hibernate5. The reference lists a dependency on hibernate 4.3.11.Final but it also lists a dependency on SpringFramework 4.2.3 which includes Hibernate5 support.

这只是一个添加额外的Hibernate5依赖关系覆盖什么Boot包?有人可以为我澄清吗?

Is it just a matter of adding the extra Hibernate5 dependencies to override what Boot bundles? Can someone please clarify for me?

推荐答案

您可以在Spring Boot 1.3中使用Hibernate 4.3或Hibernate 5.0。如您所见,Hibernate 4.3.x是默认版本。

You can use either Hibernate 4.3 or Hibernate 5.0 with Spring Boot 1.3. As you've observed, Hibernate 4.3.x is the default version.

要使用Hibernate 5.0,您应该重写 hibernate.version 属性。假设您使用的是Maven:

To use Hibernate 5.0 you should override the hibernate.version property in Spring Boot's dependency management. Assuming that you're using Maven:

<properties>
    <hibernate.version>5.0.5.Final</hibernate.version>
</properties>

使用Hibernate 5.0时,与使用Hibernate 4.3.x不同的是, Spring Boot的自定义命名策略。由于在Hibernate 5.0中发生了重大变化,你会在启动时看到类似这样的警告:

When using Hibernate 5.0, the one big difference from using Hibernate 4.3.x is that you'll lose Spring Boot's custom naming strategy. Due to a breaking change made in Hibernate 5.0, you'll see a warning like this logged at startup:

2015-12-07 10:04:56.911  WARN 81371 --- [           main] org.hibernate.orm.deprecation            : HHH90000006: Attempted to specify unsupported NamingStrategy via setting [hibernate.ejb.naming_strategy]; NamingStrategy has been removed in favor of the split ImplicitNamingStrategy and PhysicalNamingStrategy; use [hibernate.implicit_naming_strategy] or [hibernate.physical_naming_strategy], respectively, instead.

如果您不喜欢Hibernate 5的默认值,您可以在Spring Boot的 application.properties 使用 spring.jpa.properties.hibernate.implicit_naming_strategy spring.jpa。 properties.hibernate.physical_naming_strategy 属性。

If you dislike Hibernate 5's defaults, you can specify a custom implicit or physical naming strategy in Spring Boot's application.properties using the spring.jpa.properties.hibernate.implicit_naming_strategy and spring.jpa.properties.hibernate.physical_naming_strategy properties respectively.

这篇关于SpringBoot 1.3.0支持hibernate 5?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 18:12