diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.java index 54359cb70e..0c493532e1 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.java @@ -116,8 +116,13 @@ class HibernateJpaConfiguration extends JpaBaseConfiguration { ConfigurableListableBeanFactory beanFactory, List hibernatePropertiesCustomizers) { List customizers = new ArrayList<>(); - customizers.add((properties) -> properties.put(AvailableSettings.BEAN_CONTAINER, - new SpringBeanContainer(beanFactory))); + if (ClassUtils.isPresent( + "org.hibernate.resource.beans.container.spi.BeanContainer", + getClass().getClassLoader())) { + customizers + .add((properties) -> properties.put(AvailableSettings.BEAN_CONTAINER, + new SpringBeanContainer(beanFactory))); + } if (physicalNamingStrategy != null || implicitNamingStrategy != null) { customizers.add(new NamingStrategiesHibernatePropertiesCustomizer( physicalNamingStrategy, implicitNamingStrategy)); diff --git a/spring-boot-tests/spring-boot-integration-tests/pom.xml b/spring-boot-tests/spring-boot-integration-tests/pom.xml index 1091359249..a4c4bcdb5d 100644 --- a/spring-boot-tests/spring-boot-integration-tests/pom.xml +++ b/spring-boot-tests/spring-boot-integration-tests/pom.xml @@ -18,6 +18,7 @@ spring-boot-configuration-processor-tests spring-boot-devtools-tests + spring-boot-hibernate52-tests spring-boot-server-tests spring-boot-launch-script-tests diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-hibernate52-tests/pom.xml b/spring-boot-tests/spring-boot-integration-tests/spring-boot-hibernate52-tests/pom.xml new file mode 100755 index 0000000000..146815bc47 --- /dev/null +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-hibernate52-tests/pom.xml @@ -0,0 +1,44 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-integration-tests + ${revision} + + spring-boot-hibernate52-tests + Spring Boot Hibernate 5.2 tests + ${project.name} + + ${basedir}/../../.. + 5.2.17.Final + + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + + com.h2database + h2 + runtime + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-hibernate52-tests/src/main/java/org/springframework/boot/tests/hibernate52/Hibernate52Application.java b/spring-boot-tests/spring-boot-integration-tests/spring-boot-hibernate52-tests/src/main/java/org/springframework/boot/tests/hibernate52/Hibernate52Application.java new file mode 100644 index 0000000000..a6bd3d9bb8 --- /dev/null +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-hibernate52-tests/src/main/java/org/springframework/boot/tests/hibernate52/Hibernate52Application.java @@ -0,0 +1,29 @@ +/* + * Copyright 2012-2018 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.tests.hibernate52; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Hibernate52Application { + + public static void main(String[] args) { + SpringApplication.run(Hibernate52Application.class, args); + } + +} diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-hibernate52-tests/src/test/java/org/springframework/boot/tests/hibernate52/Hibernate52ApplicationTests.java b/spring-boot-tests/spring-boot-integration-tests/spring-boot-hibernate52-tests/src/test/java/org/springframework/boot/tests/hibernate52/Hibernate52ApplicationTests.java new file mode 100644 index 0000000000..898981f9a6 --- /dev/null +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-hibernate52-tests/src/test/java/org/springframework/boot/tests/hibernate52/Hibernate52ApplicationTests.java @@ -0,0 +1,34 @@ +/* + * Copyright 2012-2018 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.tests.hibernate52; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class Hibernate52ApplicationTests { + + @Test + public void contextLoads() { + + } + +}