Create spring-boot-data-jpa module

This commit is contained in:
Stéphane Nicoll
2025-03-21 11:44:31 +01:00
committed by Phillip Webb
parent 079713039d
commit 5715b90af9
38 changed files with 200 additions and 94 deletions

View File

@@ -47,6 +47,7 @@ include "spring-boot-project:spring-boot-amqp"
include "spring-boot-project:spring-boot-artemis"
include "spring-boot-project:spring-boot-autoconfigure"
include "spring-boot-project:spring-boot-autoconfigure-all"
include "spring-boot-project:spring-boot-data-jpa"
include "spring-boot-project:spring-boot-dependencies"
include "spring-boot-project:spring-boot-devtools"
include "spring-boot-project:spring-boot-docker-compose"

View File

@@ -20,12 +20,12 @@ dependencies {
optional(project(":spring-boot-project:spring-boot-activemq"))
optional(project(":spring-boot-project:spring-boot-amqp"))
optional(project(":spring-boot-project:spring-boot-artemis"))
optional(project(":spring-boot-project:spring-boot-data-jpa"))
optional(project(":spring-boot-project:spring-boot-elasticsearch"))
optional(project(":spring-boot-project:spring-boot-flyway"))
optional(project(":spring-boot-project:spring-boot-jackson"))
optional(project(":spring-boot-project:spring-boot-jdbc"))
optional(project(":spring-boot-project:spring-boot-jetty"))
optional(project(":spring-boot-project:spring-boot-jpa"))
optional(project(":spring-boot-project:spring-boot-jsonb"))
optional(project(":spring-boot-project:spring-boot-kafka"))
optional(project(":spring-boot-project:spring-boot-liquibase"))

View File

@@ -26,7 +26,7 @@ import org.springframework.boot.actuate.autoconfigure.metrics.test.MetricsRun;
import org.springframework.boot.autoconfigure.AutoConfigurationPackage;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration;
import org.springframework.boot.data.jpa.autoconfigure.JpaRepositoriesAutoConfiguration;
import org.springframework.boot.jdbc.autoconfigure.EmbeddedDataSourceConfiguration;
import org.springframework.boot.jpa.autoconfigure.hibernate.HibernateJpaAutoConfiguration;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;

View File

@@ -43,11 +43,11 @@ dependencies {
optional(project(":spring-boot-project:spring-boot-activemq"))
optional(project(":spring-boot-project:spring-boot-artemis"))
optional(project(":spring-boot-project:spring-boot-data-jpa"))
optional(project(":spring-boot-project:spring-boot-elasticsearch"))
optional(project(":spring-boot-project:spring-boot-flyway"))
optional(project(":spring-boot-project:spring-boot-jackson"))
optional(project(":spring-boot-project:spring-boot-jdbc"))
optional(project(":spring-boot-project:spring-boot-jpa"))
optional(project(":spring-boot-project:spring-boot-jsonb"))
optional(project(":spring-boot-project:spring-boot-liquibase"))
optional(project(":spring-boot-project:spring-boot-r2dbc"))
@@ -165,7 +165,6 @@ dependencies {
exclude group: "javax.persistence", module: "javax.persistence-api"
exclude group: "org.jboss.spec.javax.transaction", module: "jboss-transaction-api_1.2_spec"
}
optional("org.springframework.data:spring-data-jpa")
optional("org.springframework.data:spring-data-rest-webmvc")
optional("org.springframework.data:spring-data-cassandra") {
exclude group: "org.slf4j", module: "jcl-over-slf4j"

View File

@@ -546,18 +546,6 @@
"description": "Whether to enable JDBC repositories.",
"defaultValue": true
},
{
"name": "spring.data.jpa.repositories.bootstrap-mode",
"type": "org.springframework.data.repository.config.BootstrapMode",
"description": "Bootstrap mode for JPA repositories.",
"defaultValue": "default"
},
{
"name": "spring.data.jpa.repositories.enabled",
"type": "java.lang.Boolean",
"description": "Whether to enable JPA repositories.",
"defaultValue": true
},
{
"name": "spring.data.ldap.repositories.enabled",
"type": "java.lang.Boolean",

View File

@@ -16,7 +16,6 @@ org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchDataAutoC
org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchRepositoriesAutoConfiguration
org.springframework.boot.autoconfigure.data.elasticsearch.ReactiveElasticsearchRepositoriesAutoConfiguration
org.springframework.boot.autoconfigure.data.jdbc.JdbcRepositoriesAutoConfiguration
org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration
org.springframework.boot.autoconfigure.data.ldap.LdapRepositoriesAutoConfiguration
org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration
org.springframework.boot.autoconfigure.data.mongo.MongoReactiveDataAutoConfiguration

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2025 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.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.data.jpa.city;
package org.springframework.boot.autoconfigure.data.alt.jpa;
import java.io.Serializable;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2025 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.
@@ -16,7 +16,6 @@
package org.springframework.boot.autoconfigure.data.alt.jpa;
import org.springframework.boot.autoconfigure.data.jpa.city.City;
import org.springframework.data.repository.Repository;
public interface CityJpaRepository extends Repository<City, Long> {

View File

@@ -23,13 +23,13 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage;
import org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration;
import org.springframework.boot.autoconfigure.data.jpa.city.City;
import org.springframework.boot.autoconfigure.data.jpa.city.CityRepository;
import org.springframework.boot.autoconfigure.data.alt.jpa.City;
import org.springframework.boot.autoconfigure.data.alt.jpa.CityJpaRepository;
import org.springframework.boot.autoconfigure.data.mongo.country.Country;
import org.springframework.boot.autoconfigure.data.mongo.country.CountryRepository;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.boot.data.jpa.autoconfigure.JpaRepositoriesAutoConfiguration;
import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration;
import org.springframework.boot.jpa.autoconfigure.hibernate.HibernateJpaAutoConfiguration;
import org.springframework.boot.test.util.TestPropertyValues;
@@ -73,7 +73,7 @@ class MixedMongoRepositoriesAutoConfigurationTests {
this.context.register(MixedConfiguration.class, BaseConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(CountryRepository.class)).isNotNull();
assertThat(this.context.getBean(CityRepository.class)).isNotNull();
assertThat(this.context.getBean(CityJpaRepository.class)).isNotNull();
}
@Test
@@ -81,7 +81,7 @@ class MixedMongoRepositoriesAutoConfigurationTests {
this.context = new AnnotationConfigApplicationContext();
this.context.register(JpaConfiguration.class, BaseConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(CityRepository.class)).isNotNull();
assertThat(this.context.getBean(CityJpaRepository.class)).isNotNull();
}
@Test
@@ -89,7 +89,7 @@ class MixedMongoRepositoriesAutoConfigurationTests {
this.context = new AnnotationConfigApplicationContext();
this.context.register(OverlapConfiguration.class, BaseConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(CityRepository.class)).isNotNull();
assertThat(this.context.getBean(CityJpaRepository.class)).isNotNull();
}
@Test
@@ -98,7 +98,7 @@ class MixedMongoRepositoriesAutoConfigurationTests {
TestPropertyValues.of("spring.data.mongodb.repositories.type:none").applyTo(this.context);
this.context.register(OverlapConfiguration.class, BaseConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(CityRepository.class)).isNotNull();
assertThat(this.context.getBean(CityJpaRepository.class)).isNotNull();
}
@Configuration(proxyBeanMethods = false)
@@ -113,7 +113,7 @@ class MixedMongoRepositoriesAutoConfigurationTests {
@TestAutoConfigurationPackage(MongoAutoConfiguration.class)
@EnableMongoRepositories(basePackageClasses = Country.class)
@EntityScan(basePackageClasses = City.class)
@EnableJpaRepositories(basePackageClasses = CityRepository.class)
@EnableJpaRepositories(basePackageClasses = CityJpaRepository.class)
static class MixedConfiguration {
}
@@ -121,7 +121,7 @@ class MixedMongoRepositoriesAutoConfigurationTests {
@Configuration(proxyBeanMethods = false)
@TestAutoConfigurationPackage(MongoAutoConfiguration.class)
@EntityScan(basePackageClasses = City.class)
@EnableJpaRepositories(basePackageClasses = CityRepository.class)
@EnableJpaRepositories(basePackageClasses = CityJpaRepository.class)
static class JpaConfiguration {
}
@@ -129,8 +129,8 @@ class MixedMongoRepositoriesAutoConfigurationTests {
// In this one the Jpa repositories and the auto-configuration packages overlap, so
// Mongo will try and configure the same repositories
@Configuration(proxyBeanMethods = false)
@TestAutoConfigurationPackage(CityRepository.class)
@EnableJpaRepositories(basePackageClasses = CityRepository.class)
@TestAutoConfigurationPackage(CityJpaRepository.class)
@EnableJpaRepositories(basePackageClasses = CityJpaRepository.class)
static class OverlapConfiguration {
}

View File

@@ -25,13 +25,13 @@ import org.neo4j.driver.GraphDatabase;
import org.neo4j.driver.internal.logging.Slf4jLogging;
import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage;
import org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration;
import org.springframework.boot.autoconfigure.data.jpa.city.City;
import org.springframework.boot.autoconfigure.data.jpa.city.CityRepository;
import org.springframework.boot.autoconfigure.data.alt.jpa.City;
import org.springframework.boot.autoconfigure.data.alt.jpa.CityJpaRepository;
import org.springframework.boot.autoconfigure.data.neo4j.country.Country;
import org.springframework.boot.autoconfigure.data.neo4j.country.CountryRepository;
import org.springframework.boot.autoconfigure.data.neo4j.empty.EmptyMarker;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.data.jpa.autoconfigure.JpaRepositoriesAutoConfiguration;
import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration;
import org.springframework.boot.jpa.autoconfigure.hibernate.HibernateJpaAutoConfiguration;
import org.springframework.boot.test.util.TestPropertyValues;
@@ -75,26 +75,26 @@ class MixedNeo4jRepositoriesAutoConfigurationTests {
void testMixedRepositoryConfiguration() {
load(MixedConfiguration.class);
assertThat(this.context.getBean(CountryRepository.class)).isNotNull();
assertThat(this.context.getBean(CityRepository.class)).isNotNull();
assertThat(this.context.getBean(CityJpaRepository.class)).isNotNull();
}
@Test
void testJpaRepositoryConfigurationWithNeo4jTemplate() {
load(JpaConfiguration.class);
assertThat(this.context.getBean(CityRepository.class)).isNotNull();
assertThat(this.context.getBean(CityJpaRepository.class)).isNotNull();
}
@Test
@Disabled
void testJpaRepositoryConfigurationWithNeo4jOverlap() {
load(OverlapConfiguration.class);
assertThat(this.context.getBean(CityRepository.class)).isNotNull();
assertThat(this.context.getBean(CityJpaRepository.class)).isNotNull();
}
@Test
void testJpaRepositoryConfigurationWithNeo4jOverlapDisabled() {
load(OverlapConfiguration.class, "spring.data.neo4j.repositories.enabled:false");
assertThat(this.context.getBean(CityRepository.class)).isNotNull();
assertThat(this.context.getBean(CityJpaRepository.class)).isNotNull();
}
private void load(Class<?> config, String... environment) {
@@ -128,7 +128,7 @@ class MixedNeo4jRepositoriesAutoConfigurationTests {
@TestAutoConfigurationPackage(EmptyMarker.class)
@EnableNeo4jRepositories(basePackageClasses = Country.class)
@EntityScan(basePackageClasses = City.class)
@EnableJpaRepositories(basePackageClasses = CityRepository.class)
@EnableJpaRepositories(basePackageClasses = CityJpaRepository.class)
static class MixedConfiguration extends AbstractNeo4jConfig {
@Override
@@ -143,7 +143,7 @@ class MixedNeo4jRepositoriesAutoConfigurationTests {
@Configuration(proxyBeanMethods = false)
@TestAutoConfigurationPackage(EmptyMarker.class)
@EntityScan(basePackageClasses = City.class)
@EnableJpaRepositories(basePackageClasses = CityRepository.class)
@EnableJpaRepositories(basePackageClasses = CityJpaRepository.class)
static class JpaConfiguration {
}
@@ -151,8 +151,8 @@ class MixedNeo4jRepositoriesAutoConfigurationTests {
// In this one the Jpa repositories and the auto-configuration packages overlap, so
// Neo4j will try and configure the same repositories
@Configuration(proxyBeanMethods = false)
@TestAutoConfigurationPackage(CityRepository.class)
@EnableJpaRepositories(basePackageClasses = CityRepository.class)
@TestAutoConfigurationPackage(CityJpaRepository.class)
@EnableJpaRepositories(basePackageClasses = CityJpaRepository.class)
static class OverlapConfiguration {
}

View File

@@ -24,8 +24,8 @@ import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration;
import org.springframework.boot.autoconfigure.data.jpa.city.City;
import org.springframework.boot.autoconfigure.data.alt.jpa.City;
import org.springframework.boot.data.jpa.autoconfigure.JpaRepositoriesAutoConfiguration;
import org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration;
import org.springframework.boot.jdbc.autoconfigure.EmbeddedDataSourceConfiguration;
import org.springframework.boot.jpa.autoconfigure.hibernate.HibernateJpaAutoConfiguration;

View File

@@ -20,9 +20,9 @@ import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage;
import org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration;
import org.springframework.boot.autoconfigure.data.jpa.city.City;
import org.springframework.boot.autoconfigure.data.jpa.city.CityRepository;
import org.springframework.boot.autoconfigure.data.alt.jpa.City;
import org.springframework.boot.autoconfigure.data.alt.jpa.CityJpaRepository;
import org.springframework.boot.data.jpa.autoconfigure.JpaRepositoriesAutoConfiguration;
import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration;
import org.springframework.boot.jpa.autoconfigure.hibernate.HibernateJpaAutoConfiguration;
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
@@ -52,7 +52,7 @@ class SpringDataWebAutoConfigurationJpaTests {
@Test
void springDataWebIsConfiguredWithJpaRepositories() {
this.contextRunner.withUserConfiguration(TestConfiguration.class).run((context) -> {
assertThat(context).hasSingleBean(CityRepository.class);
assertThat(context).hasSingleBean(CityJpaRepository.class);
assertThat(context).hasSingleBean(PageableHandlerMethodArgumentResolver.class);
assertThat(context).hasSingleBean(SortHandlerMethodArgumentResolver.class);
assertThat(context.getBean(FormattingConversionService.class).canConvert(String.class, Distance.class))

View File

@@ -16,6 +16,7 @@ dependencies {
optional("jakarta.persistence:jakarta.persistence-api")
optional("jakarta.servlet:jakarta.servlet-api")
optional("org.springframework:spring-web")
optional("org.springframework.data:spring-data-commons")
testFixturesCompileOnly(project(":spring-boot-project:spring-boot-test"))
testFixturesCompileOnly(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support"))

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2025 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2025 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2025 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2025 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.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 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.

View File

@@ -0,0 +1,32 @@
plugins {
id "java-library"
id "org.springframework.boot.auto-configuration"
id "org.springframework.boot.configuration-properties"
id "org.springframework.boot.deployed"
id "org.springframework.boot.optional-dependencies"
}
description = "Spring Boot Data JPA"
dependencies {
api(project(":spring-boot-project:spring-boot-jpa"))
api("org.springframework.data:spring-data-jpa")
api("org.springframework:spring-aspects")
optional(project(":spring-boot-project:spring-boot-autoconfigure"))
optional("org.springframework.data:spring-data-envers") {
exclude group: "javax.activation", module: "javax.activation-api"
exclude group: "javax.persistence", module: "javax.persistence-api"
exclude group: "javax.xml.bind", module: "jaxb-api"
exclude group: "org.jboss.spec.javax.transaction", module: "jboss-transaction-api_1.2_spec"
}
testImplementation(project(":spring-boot-project:spring-boot-jdbc"))
testImplementation(project(":spring-boot-project:spring-boot-test"))
testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support"))
testImplementation(testFixtures(project(":spring-boot-project:spring-boot-autoconfigure")))
testRuntimeOnly("ch.qos.logback:logback-classic")
testRuntimeOnly("com.h2database:h2")
testRuntimeOnly("com.zaxxer:HikariCP")
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.data.jpa;
package org.springframework.boot.data.jpa.autoconfigure;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.data.envers.repository.support.EnversRevisionRepositoryFactoryBean;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.data.jpa;
package org.springframework.boot.data.jpa.autoconfigure;
import java.util.Map;
@@ -28,8 +28,8 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnBooleanProp
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration.JpaRepositoriesImportSelector;
import org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration;
import org.springframework.boot.data.jpa.autoconfigure.JpaRepositoriesAutoConfiguration.JpaRepositoriesImportSelector;
import org.springframework.boot.jpa.autoconfigure.EntityManagerFactoryBuilderCustomizer;
import org.springframework.boot.jpa.autoconfigure.hibernate.HibernateJpaAutoConfiguration;
import org.springframework.context.annotation.Bean;
@@ -68,7 +68,7 @@ import org.springframework.util.ClassUtils;
* @author Josh Long
* @author Scott Frederick
* @author Stefano Cordio
* @since 1.0.0
* @since 4.0.0
* @see EnableJpaRepositories
*/
@AutoConfiguration(after = { HibernateJpaAutoConfiguration.class, TaskExecutionAutoConfiguration.class })

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 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.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.data.jpa;
package org.springframework.boot.data.jpa.autoconfigure;
import java.lang.annotation.Annotation;
import java.util.Locale;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2025 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.
@@ -17,4 +17,4 @@
/**
* Auto-configuration for Spring Data JPA.
*/
package org.springframework.boot.autoconfigure.data.jpa;
package org.springframework.boot.data.jpa.autoconfigure;

View File

@@ -0,0 +1,17 @@
{
"groups": [],
"properties": [
{
"name": "spring.data.jpa.repositories.bootstrap-mode",
"type": "org.springframework.data.repository.config.BootstrapMode",
"description": "Bootstrap mode for JPA repositories.",
"defaultValue": "default"
},
{
"name": "spring.data.jpa.repositories.enabled",
"type": "java.lang.Boolean",
"description": "Whether to enable JPA repositories.",
"defaultValue": true
}
]
}

View File

@@ -0,0 +1 @@
org.springframework.boot.data.jpa.autoconfigure.JpaRepositoriesAutoConfiguration

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.data.jpa;
package org.springframework.boot.data.jpa.autoconfigure;
import jakarta.persistence.EntityManagerFactory;
import org.junit.jupiter.api.Test;
@@ -22,21 +22,16 @@ import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.data.alt.elasticsearch.CityElasticsearchDbRepository;
import org.springframework.boot.autoconfigure.data.alt.jpa.CityJpaRepository;
import org.springframework.boot.autoconfigure.data.alt.mongo.CityMongoDbRepository;
import org.springframework.boot.autoconfigure.data.jpa.city.City;
import org.springframework.boot.autoconfigure.data.jpa.city.CityRepository;
import org.springframework.boot.autoconfigure.data.jpa.country.Country;
import org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration;
import org.springframework.boot.autoconfigure.task.TaskSchedulingAutoConfiguration;
import org.springframework.boot.data.jpa.autoconfigure.domain.city.City;
import org.springframework.boot.data.jpa.autoconfigure.domain.city.CityRepository;
import org.springframework.boot.data.jpa.autoconfigure.domain.country.Country;
import org.springframework.boot.jdbc.autoconfigure.EmbeddedDataSourceConfiguration;
import org.springframework.boot.jpa.autoconfigure.hibernate.HibernateJpaAutoConfiguration;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.context.annotation.Import;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
@@ -74,7 +69,7 @@ abstract class AbstractJpaRepositoriesAutoConfigurationTests {
@Test
void testOverrideRepositoryConfiguration() {
this.contextRunner.withUserConfiguration(CustomConfiguration.class).run((context) -> {
assertThat(context).hasSingleBean(CityJpaRepository.class);
assertThat(context).hasSingleBean(CityRepository.class);
assertThat(context).hasSingleBean(PlatformTransactionManager.class);
assertThat(context).hasSingleBean(EntityManagerFactory.class);
});
@@ -163,10 +158,7 @@ abstract class AbstractJpaRepositoriesAutoConfigurationTests {
}
@Configuration(proxyBeanMethods = false)
@EnableJpaRepositories(
basePackageClasses = org.springframework.boot.autoconfigure.data.alt.jpa.CityJpaRepository.class,
excludeFilters = { @Filter(type = FilterType.ASSIGNABLE_TYPE, value = CityMongoDbRepository.class),
@Filter(type = FilterType.ASSIGNABLE_TYPE, value = CityElasticsearchDbRepository.class) })
@EnableJpaRepositories(basePackageClasses = CityRepository.class)
@TestAutoConfigurationPackage(City.class)
static class CustomConfiguration {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 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.
@@ -14,11 +14,11 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.data.jpa;
package org.springframework.boot.data.jpa.autoconfigure;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.data.jpa.country.CountryRepository;
import org.springframework.boot.data.jpa.autoconfigure.domain.country.CountryRepository;
import static org.assertj.core.api.Assertions.assertThat;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 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.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.data.jpa;
package org.springframework.boot.data.jpa.autoconfigure;
import org.junit.jupiter.api.Test;

View File

@@ -0,0 +1,76 @@
/*
* Copyright 2012-2025 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
*
* https://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.data.jpa.autoconfigure.domain.city;
import java.io.Serializable;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
@Entity
public class City implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue
private Long id;
@Column(nullable = false)
private String name;
@Column(nullable = false)
private String state;
@Column(nullable = false)
private String country;
@Column(nullable = false)
private String map;
protected City() {
}
public City(String name, String country) {
this.name = name;
this.country = country;
}
public String getName() {
return this.name;
}
public String getState() {
return this.state;
}
public String getCountry() {
return this.country;
}
public String getMap() {
return this.map;
}
@Override
public String toString() {
return getName() + "," + getState() + "," + getCountry();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2025 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.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.data.jpa.city;
package org.springframework.boot.data.jpa.autoconfigure.domain.city;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2025 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.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.data.jpa.country;
package org.springframework.boot.data.jpa.autoconfigure.domain.country;
import java.io.Serializable;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2025 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.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.data.jpa.country;
package org.springframework.boot.data.jpa.autoconfigure.domain.country;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.history.RevisionRepository;

View File

@@ -1984,6 +1984,7 @@ bom {
"spring-boot-buildpack-platform",
"spring-boot-configuration-metadata",
"spring-boot-configuration-processor",
"spring-boot-data-jpa",
"spring-boot-devtools",
"spring-boot-docker-compose",
"spring-boot-elasticsearch",

View File

@@ -65,6 +65,7 @@ dependencies {
autoConfiguration(project(path: ":spring-boot-project:spring-boot-artemis", configuration: "autoConfigurationMetadata"))
autoConfiguration(project(path: ":spring-boot-project:spring-boot-autoconfigure", configuration: "autoConfigurationMetadata"))
autoConfiguration(project(path: ":spring-boot-project:spring-boot-autoconfigure-all", configuration: "autoConfigurationMetadata"))
autoConfiguration(project(path: ":spring-boot-project:spring-boot-data-jpa", configuration: "autoConfigurationMetadata"))
autoConfiguration(project(path: ":spring-boot-project:spring-boot-devtools", configuration: "autoConfigurationMetadata"))
autoConfiguration(project(path: ":spring-boot-project:spring-boot-elasticsearch", configuration: "autoConfigurationMetadata"))
autoConfiguration(project(path: ":spring-boot-project:spring-boot-flyway", configuration: "autoConfigurationMetadata"))
@@ -95,6 +96,7 @@ dependencies {
configurationProperties(project(path: ":spring-boot-project:spring-boot-artemis", configuration: "configurationPropertiesMetadata"))
configurationProperties(project(path: ":spring-boot-project:spring-boot-autoconfigure", configuration: "configurationPropertiesMetadata"))
configurationProperties(project(path: ":spring-boot-project:spring-boot-autoconfigure-all", configuration: "configurationPropertiesMetadata"))
configurationProperties(project(path: ":spring-boot-project:spring-boot-data-jpa", configuration: "configurationPropertiesMetadata"))
configurationProperties(project(path: ":spring-boot-project:spring-boot-devtools", configuration: "configurationPropertiesMetadata"))
configurationProperties(project(path: ":spring-boot-project:spring-boot-docker-compose", configuration: "configurationPropertiesMetadata"))
configurationProperties(project(path: ":spring-boot-project:spring-boot-elasticsearch", configuration: "configurationPropertiesMetadata"))

View File

@@ -5,9 +5,7 @@ plugins {
description = "Starter for using Spring Data JPA with Hibernate"
dependencies {
api(project(":spring-boot-project:spring-boot-jpa"))
api(project(":spring-boot-project:spring-boot-data-jpa"))
api(project(":spring-boot-project:spring-boot-starters:spring-boot-starter"))
api(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-jdbc"))
api("org.springframework.data:spring-data-jpa")
api("org.springframework:spring-aspects")
}

View File

@@ -36,12 +36,12 @@ dependencies {
dockerTestRuntimeOnly("io.lettuce:lettuce-core")
dockerTestRuntimeOnly("org.springframework.data:spring-data-redis")
optional(project(":spring-boot-project:spring-boot-data-jpa"))
optional(project(":spring-boot-project:spring-boot-elasticsearch"))
optional(project(":spring-boot-project:spring-boot-flyway"))
optional(project(":spring-boot-project:spring-boot-groovy-templates"))
optional(project(":spring-boot-project:spring-boot-jackson"))
optional(project(":spring-boot-project:spring-boot-jdbc"))
optional(project(":spring-boot-project:spring-boot-jpa"))
optional(project(":spring-boot-project:spring-boot-jsonb"))
optional(project(":spring-boot-project:spring-boot-liquibase")) {
exclude(group: "org.liquibase")

View File

@@ -1,5 +1,5 @@
# AutoConfigureDataJpa auto-configuration imports
org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration
org.springframework.boot.data.jpa.autoconfigure.JpaRepositoriesAutoConfiguration
org.springframework.boot.jpa.autoconfigure.hibernate.HibernateJpaAutoConfiguration
org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration
org.springframework.boot.jdbc.autoconfigure.DataSourceInitializationAutoConfiguration