Introduce spring-boot-persistence

This commit adds a spring-boot-persistence module with data technology
independent features. This provides a better home for EntityScan and
PersistenceExceptionTranslationAutoConfiguration.

Closes gh-45328
This commit is contained in:
Stéphane Nicoll
2025-09-17 14:42:22 +02:00
parent b71d6475c3
commit cdd39bafd7
46 changed files with 121 additions and 65 deletions
@@ -130,7 +130,7 @@ public abstract class DocumentConfigurationProperties extends DefaultTask {
config.accept("spring.ldap");
config.accept("spring.mongodb");
config.accept("spring.neo4j");
config.accept("spring.dao");
config.accept("spring.persistence");
config.accept("spring.data");
config.accept("spring.datasource");
config.accept("spring.jooq");
@@ -30,7 +30,6 @@ dependencies {
optional("com.github.ben-manes.caffeine:caffeine")
optional("org.aspectj:aspectjweaver")
optional("jakarta.persistence:jakarta.persistence-api")
optional("jakarta.servlet:jakarta.servlet-api")
optional("javax.money:money-api")
optional("org.springframework:spring-web")
@@ -105,6 +105,7 @@ dependencies {
implementation(project(path: ":module:spring-boot-jsonb"))
implementation(project(path: ":module:spring-boot-ldap"))
implementation(project(path: ":module:spring-boot-micrometer-metrics"))
implementation(project(path: ":module:spring-boot-persistence"))
implementation(project(path: ":module:spring-boot-r2dbc"))
implementation(project(path: ":module:spring-boot-reactor-netty"))
implementation(project(path: ":module:spring-boot-restclient"))
@@ -176,7 +176,7 @@ For more about Spring Data, see the {url-spring-data-site}[Spring Data project p
== Separate @Entity Definitions from Spring Configuration
Spring Boot determines the location of your javadoc:jakarta.persistence.Entity[format=annotation] definitions by scanning the xref:reference:using/auto-configuration.adoc#using.auto-configuration.packages[auto-configuration packages].
For more control, use the javadoc:org.springframework.boot.autoconfigure.domain.EntityScan[format=annotation] annotation, as shown in the following example:
For more control, use the javadoc:org.springframework.boot.persistence.autoconfigure.EntityScan[format=annotation] annotation, as shown in the following example:
include-code::MyApplication[]
@@ -220,7 +220,7 @@ include-code::CityRepository[]
Repositories and documents are found through scanning.
By default, the xref:using/auto-configuration.adoc#using.auto-configuration.packages[auto-configuration packages] are scanned.
You can customize the locations to look for repositories and documents by using javadoc:org.springframework.data.mongodb.repository.config.EnableMongoRepositories[format=annotation] and javadoc:org.springframework.boot.autoconfigure.domain.EntityScan[format=annotation] respectively.
You can customize the locations to look for repositories and documents by using javadoc:org.springframework.data.mongodb.repository.config.EnableMongoRepositories[format=annotation] and javadoc:org.springframework.boot.persistence.autoconfigure.EntityScan[format=annotation] respectively.
TIP: For complete details of Spring Data MongoDB, including its rich object mapping technologies, see its {url-spring-data-mongodb-docs}[reference documentation].
@@ -279,7 +279,7 @@ When Project Reactor is available on the classpath, the reactive style is also a
Repositories and entities are found through scanning.
By default, the xref:using/auto-configuration.adoc#using.auto-configuration.packages[auto-configuration packages] are scanned.
You can customize the locations to look for repositories and entities by using javadoc:org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories[format=annotation] and javadoc:org.springframework.boot.autoconfigure.domain.EntityScan[format=annotation] respectively.
You can customize the locations to look for repositories and entities by using javadoc:org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories[format=annotation] and javadoc:org.springframework.boot.persistence.autoconfigure.EntityScan[format=annotation] respectively.
[NOTE]
====
@@ -402,7 +402,7 @@ You could take the JPA example from earlier and, assuming that `City` is now an
Repositories and documents are found through scanning.
By default, the xref:using/auto-configuration.adoc#using.auto-configuration.packages[auto-configuration packages] are scanned.
You can customize the locations to look for repositories and documents by using javadoc:org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories[format=annotation] and javadoc:org.springframework.boot.autoconfigure.domain.EntityScan[format=annotation] respectively.
You can customize the locations to look for repositories and documents by using javadoc:org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories[format=annotation] and javadoc:org.springframework.boot.persistence.autoconfigure.EntityScan[format=annotation] respectively.
TIP: For complete details of Spring Data Elasticsearch, see the {url-spring-data-elasticsearch-docs}[reference documentation].
@@ -520,7 +520,7 @@ Currently, this is more limited than the JPA repositories discussed earlier and
Repositories and entities are found through scanning.
By default, the xref:using/auto-configuration.adoc#using.auto-configuration.packages[auto-configuration packages] are scanned.
You can customize the locations to look for repositories and entities by using javadoc:org.springframework.data.cassandra.repository.config.EnableCassandraRepositories[format=annotation] and javadoc:org.springframework.boot.autoconfigure.domain.EntityScan[format=annotation] respectively.
You can customize the locations to look for repositories and entities by using javadoc:org.springframework.data.cassandra.repository.config.EnableCassandraRepositories[format=annotation] and javadoc:org.springframework.boot.persistence.autoconfigure.EntityScan[format=annotation] respectively.
TIP: For complete details of Spring Data Cassandra, see the {url-spring-data-cassandra-docs}[reference documentation].
@@ -610,7 +610,7 @@ Spring Data includes repository support for Couchbase.
Repositories and documents are found through scanning.
By default, the xref:using/auto-configuration.adoc#using.auto-configuration.packages[auto-configuration packages] are scanned.
You can customize the locations to look for repositories and documents by using javadoc:org.springframework.data.couchbase.repository.config.EnableCouchbaseRepositories[format=annotation] and javadoc:org.springframework.boot.autoconfigure.domain.EntityScan[format=annotation] respectively.
You can customize the locations to look for repositories and documents by using javadoc:org.springframework.data.couchbase.repository.config.EnableCouchbaseRepositories[format=annotation] and javadoc:org.springframework.boot.persistence.autoconfigure.EntityScan[format=annotation] respectively.
For complete details of Spring Data Couchbase, see the {url-spring-data-couchbase-docs}[reference documentation].
@@ -683,7 +683,7 @@ Spring Data includes repository support for LDAP.
Repositories and documents are found through scanning.
By default, the xref:using/auto-configuration.adoc#using.auto-configuration.packages[auto-configuration packages] are scanned.
You can customize the locations to look for repositories and documents by using javadoc:org.springframework.data.ldap.repository.config.EnableLdapRepositories[format=annotation] and javadoc:org.springframework.boot.autoconfigure.domain.EntityScan[format=annotation] respectively.
You can customize the locations to look for repositories and documents by using javadoc:org.springframework.data.ldap.repository.config.EnableLdapRepositories[format=annotation] and javadoc:org.springframework.boot.persistence.autoconfigure.EntityScan[format=annotation] respectively.
TIP: For complete details of Spring Data LDAP, see the {url-spring-data-ldap-docs}[reference documentation].
@@ -227,7 +227,7 @@ A typical entity class resembles the following example:
include-code::City[]
TIP: You can customize entity scanning locations by using the javadoc:org.springframework.boot.autoconfigure.domain.EntityScan[format=annotation] annotation.
TIP: You can customize entity scanning locations by using the javadoc:org.springframework.boot.persistence.autoconfigure.EntityScan[format=annotation] annotation.
See the xref:how-to:data-access.adoc#howto.data-access.separate-entity-definitions-from-spring-configuration[] section of the "`How-to Guides`".
@@ -13,7 +13,7 @@ TIP: If you wish to enforce a structure based on domains, take a look at https:/
When a class does not include a `package` declaration, it is considered to be in the "`default package`".
The use of the "`default package`" is generally discouraged and should be avoided.
It can cause particular problems for Spring Boot applications that use the javadoc:org.springframework.context.annotation.ComponentScan[format=annotation], javadoc:org.springframework.boot.context.properties.ConfigurationPropertiesScan[format=annotation], javadoc:org.springframework.boot.autoconfigure.domain.EntityScan[format=annotation], or javadoc:org.springframework.boot.autoconfigure.SpringBootApplication[format=annotation] annotations, since every class from every jar is read.
It can cause particular problems for Spring Boot applications that use the javadoc:org.springframework.context.annotation.ComponentScan[format=annotation], javadoc:org.springframework.boot.context.properties.ConfigurationPropertiesScan[format=annotation], javadoc:org.springframework.boot.persistence.autoconfigure.EntityScan[format=annotation], or javadoc:org.springframework.boot.autoconfigure.SpringBootApplication[format=annotation] annotations, since every class from every jar is read.
TIP: We recommend that you follow Java's recommended package naming conventions and use a reversed domain name (for example, `com.example.project`).
@@ -17,7 +17,7 @@
package org.springframework.boot.docs.howto.dataaccess.separateentitydefinitionsfromspringconfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.persistence.autoconfigure.EntityScan;
import org.springframework.context.annotation.Configuration;
@Configuration(proxyBeanMethods = false)
@@ -17,7 +17,7 @@
package org.springframework.boot.docs.howto.dataaccess.separateentitydefinitionsfromspringconfiguration
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.boot.autoconfigure.domain.EntityScan
import org.springframework.boot.persistence.autoconfigure.EntityScan
import org.springframework.context.annotation.Configuration
@Configuration(proxyBeanMethods = false)
@@ -28,9 +28,9 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.domain.EntityScanPackages;
import org.springframework.boot.cassandra.autoconfigure.CassandraAutoConfiguration;
import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.boot.persistence.autoconfigure.EntityScanPackages;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Lazy;
import org.springframework.core.env.Environment;
@@ -22,9 +22,9 @@ import com.datastax.oss.driver.api.core.CqlSession;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.cassandra.autoconfigure.CassandraAutoConfiguration;
import org.springframework.boot.data.cassandra.domain.city.City;
import org.springframework.boot.persistence.autoconfigure.EntityScan;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
@@ -19,9 +19,9 @@ package org.springframework.boot.data.cassandra.autoconfigure;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.cassandra.autoconfigure.CassandraAutoConfiguration;
import org.springframework.boot.data.cassandra.domain.city.City;
import org.springframework.boot.persistence.autoconfigure.EntityScan;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.cassandra.core.ReactiveCassandraTemplate;
@@ -26,6 +26,7 @@ description = "Spring Boot Data Commons"
dependencies {
api(project(":core:spring-boot"))
api(project(":module:spring-boot-persistence"))
api("org.springframework.data:spring-data-commons")
optional(project(":core:spring-boot-autoconfigure"))
@@ -20,7 +20,7 @@ import java.util.Collections;
import org.springframework.beans.BeanUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.domain.EntityScanner;
import org.springframework.boot.persistence.autoconfigure.EntityScanner;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -21,10 +21,10 @@ import java.util.Collections;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.couchbase.autoconfigure.CouchbaseAutoConfiguration;
import org.springframework.boot.couchbase.autoconfigure.CouchbaseProperties;
import org.springframework.boot.data.couchbase.domain.city.City;
import org.springframework.boot.persistence.autoconfigure.EntityScan;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.validation.autoconfigure.ValidationAutoConfiguration;
import org.springframework.context.annotation.Bean;
@@ -21,10 +21,10 @@ import java.util.Collections;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.couchbase.autoconfigure.CouchbaseAutoConfiguration;
import org.springframework.boot.couchbase.autoconfigure.CouchbaseProperties;
import org.springframework.boot.data.couchbase.domain.city.City;
import org.springframework.boot.persistence.autoconfigure.EntityScan;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.validation.autoconfigure.ValidationAutoConfiguration;
import org.springframework.context.annotation.Bean;
@@ -23,7 +23,7 @@ import co.elastic.clients.elasticsearch.ElasticsearchClient;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.domain.EntityScanner;
import org.springframework.boot.persistence.autoconfigure.EntityScanner;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -25,10 +25,10 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBooleanProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.domain.EntityScanner;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.jdbc.autoconfigure.DataSourceTransactionManagerAutoConfiguration;
import org.springframework.boot.jdbc.autoconfigure.JdbcTemplateAutoConfiguration;
import org.springframework.boot.persistence.autoconfigure.EntityScanner;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -19,8 +19,8 @@ package org.springframework.boot.data.mongodb.autoconfigure;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.domain.EntityScanner;
import org.springframework.boot.context.properties.PropertyMapper;
import org.springframework.boot.persistence.autoconfigure.EntityScanner;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -32,12 +32,12 @@ import org.springframework.beans.factory.BeanCreationException;
import org.springframework.boot.autoconfigure.AutoConfigurationPackages;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.data.mongodb.autoconfigure.domain.city.City;
import org.springframework.boot.data.mongodb.autoconfigure.domain.country.Country;
import org.springframework.boot.mongodb.autoconfigure.MongoAutoConfiguration;
import org.springframework.boot.mongodb.autoconfigure.MongoConnectionDetails;
import org.springframework.boot.mongodb.autoconfigure.PropertiesMongoConnectionDetails;
import org.springframework.boot.persistence.autoconfigure.EntityScan;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
@@ -26,9 +26,9 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.domain.EntityScanner;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.neo4j.autoconfigure.Neo4jAutoConfiguration;
import org.springframework.boot.persistence.autoconfigure.EntityScanner;
import org.springframework.boot.transaction.autoconfigure.TransactionAutoConfiguration;
import org.springframework.boot.transaction.autoconfigure.TransactionManagerCustomizationAutoConfiguration;
import org.springframework.boot.transaction.autoconfigure.TransactionManagerCustomizers;
@@ -26,7 +26,7 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnSingleCandidate;
import org.springframework.boot.autoconfigure.domain.EntityScanner;
import org.springframework.boot.persistence.autoconfigure.EntityScanner;
import org.springframework.boot.r2dbc.autoconfigure.R2dbcAutoConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
@@ -37,9 +37,9 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingFilterBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
import org.springframework.boot.autoconfigure.domain.EntityScanPackages;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.jpa.EntityManagerFactoryBuilder;
import org.springframework.boot.persistence.autoconfigure.EntityScanPackages;
import org.springframework.boot.transaction.autoconfigure.TransactionManagerCustomizers;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -0,0 +1,43 @@
/*
* Copyright 2012-present 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.
*/
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 Persistence"
dependencies {
api(project(":core:spring-boot"))
api("org.springframework:spring-tx")
optional(project(":core:spring-boot-autoconfigure"))
testImplementation(project(":core:spring-boot-test"))
testImplementation(project(":test-support:spring-boot-test-support"))
testImplementation("com.zaxxer:HikariCP")
testImplementation("jakarta.persistence:jakarta.persistence-api")
testImplementation("org.hibernate.orm:hibernate-core")
testImplementation("org.hsqldb:hsqldb")
testImplementation("org.springframework:spring-jdbc")
testImplementation("org.springframework:spring-orm")
testRuntimeOnly("ch.qos.logback:logback-classic")
}
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.domain;
package org.springframework.boot.persistence.autoconfigure;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.domain;
package org.springframework.boot.persistence.autoconfigure;
import java.util.ArrayList;
import java.util.Arrays;
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.domain;
package org.springframework.boot.persistence.autoconfigure;
import java.lang.annotation.Annotation;
import java.util.Collections;
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.transaction.autoconfigure;
package org.springframework.boot.persistence.autoconfigure;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@@ -40,7 +40,7 @@ public final class PersistenceExceptionTranslationAutoConfiguration {
@Bean
@ConditionalOnMissingBean
@ConditionalOnBooleanProperty(name = "spring.dao.exceptiontranslation.enabled", matchIfMissing = true)
@ConditionalOnBooleanProperty(name = "spring.persistence.exceptiontranslation.enabled", matchIfMissing = true)
static PersistenceExceptionTranslationPostProcessor persistenceExceptionTranslationPostProcessor(
Environment environment) {
PersistenceExceptionTranslationPostProcessor postProcessor = new PersistenceExceptionTranslationPostProcessor();
@@ -18,6 +18,6 @@
* General purpose domain annotations and classes.
*/
@NullMarked
package org.springframework.boot.autoconfigure.domain;
package org.springframework.boot.persistence.autoconfigure;
import org.jspecify.annotations.NullMarked;
@@ -0,0 +1,18 @@
{
"properties": [
{
"name": "spring.dao.exceptiontranslation.enabled",
"type": "java.lang.Boolean",
"deprecation": {
"replacement": "spring.persistence.exceptiontranslation.enabled",
"level": "error"
}
},
{
"name": "spring.persistence.exceptiontranslation.enabled",
"type": "java.lang.Boolean",
"description": "Whether to enable the PersistenceExceptionTranslationPostProcessor.",
"defaultValue": true
}
]
}
@@ -0,0 +1 @@
org.springframework.boot.persistence.autoconfigure.PersistenceExceptionTranslationAutoConfiguration
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.domain;
package org.springframework.boot.persistence.autoconfigure;
import java.util.Collection;
import java.util.Collections;
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.domain;
package org.springframework.boot.persistence.autoconfigure;
import java.util.Collections;
import java.util.Set;
@@ -23,12 +23,12 @@ import jakarta.persistence.Embeddable;
import jakarta.persistence.Entity;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.domain.scan.a.EmbeddableA;
import org.springframework.boot.autoconfigure.domain.scan.a.EntityA;
import org.springframework.boot.autoconfigure.domain.scan.b.EmbeddableB;
import org.springframework.boot.autoconfigure.domain.scan.b.EntityB;
import org.springframework.boot.autoconfigure.domain.scan.c.EmbeddableC;
import org.springframework.boot.autoconfigure.domain.scan.c.EntityC;
import org.springframework.boot.persistence.autoconfigure.scan.a.EmbeddableA;
import org.springframework.boot.persistence.autoconfigure.scan.a.EntityA;
import org.springframework.boot.persistence.autoconfigure.scan.b.EmbeddableB;
import org.springframework.boot.persistence.autoconfigure.scan.b.EntityB;
import org.springframework.boot.persistence.autoconfigure.scan.c.EmbeddableC;
import org.springframework.boot.persistence.autoconfigure.scan.c.EntityC;
import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
@@ -68,7 +68,7 @@ class EntityScannerTests {
@Test
void scanShouldScanFromResolvedPlaceholderPackage() throws Exception {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
TestPropertyValues.of("com.example.entity-package=org.springframework.boot.autoconfigure.domain.scan")
TestPropertyValues.of("com.example.entity-package=org.springframework.boot.persistence.autoconfigure.scan")
.applyTo(context);
context.register(ScanPlaceholderConfig.class);
context.refresh();
@@ -104,7 +104,8 @@ class EntityScannerTests {
void scanShouldUseCustomCandidateComponentProvider() throws ClassNotFoundException {
ClassPathScanningCandidateComponentProvider candidateComponentProvider = mock(
ClassPathScanningCandidateComponentProvider.class);
given(candidateComponentProvider.findCandidateComponents("org.springframework.boot.autoconfigure.domain.scan"))
given(candidateComponentProvider
.findCandidateComponents("org.springframework.boot.persistence.autoconfigure.scan"))
.willReturn(Collections.emptySet());
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ScanConfig.class);
TestEntityScanner scanner = new TestEntityScanner(context, candidateComponentProvider);
@@ -114,7 +115,7 @@ class EntityScannerTests {
assertArg((typeFilter) -> assertThat(typeFilter).isInstanceOfSatisfying(AnnotationTypeFilter.class,
(filter) -> assertThat(filter.getAnnotationType()).isEqualTo(Entity.class))));
then(candidateComponentProvider).should()
.findCandidateComponents("org.springframework.boot.autoconfigure.domain.scan");
.findCandidateComponents("org.springframework.boot.persistence.autoconfigure.scan");
then(candidateComponentProvider).shouldHaveNoMoreInteractions();
}
@@ -122,7 +123,7 @@ class EntityScannerTests {
void scanShouldScanCommaSeparatedPackagesInPlaceholderPackage() throws Exception {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
TestPropertyValues
.of("com.example.entity-package=org.springframework.boot.autoconfigure.domain.scan.a,org.springframework.boot.autoconfigure.domain.scan.b")
.of("com.example.entity-package=org.springframework.boot.persistence.autoconfigure.scan.a,org.springframework.boot.persistence.autoconfigure.scan.b")
.applyTo(context);
context.register(ScanPlaceholderConfig.class);
context.refresh();
@@ -151,7 +152,7 @@ class EntityScannerTests {
}
@Configuration(proxyBeanMethods = false)
@EntityScan("org.springframework.boot.autoconfigure.domain.scan")
@EntityScan("org.springframework.boot.persistence.autoconfigure.scan")
static class ScanConfig {
}
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.transaction.autoconfigure;
package org.springframework.boot.persistence.autoconfigure;
import java.io.Serializable;
import java.lang.annotation.ElementType;
@@ -93,7 +93,7 @@ class PersistenceExceptionTranslationAutoConfigurationTests {
@Test
void exceptionTranslationPostProcessorCanBeDisabled() {
this.context = new AnnotationConfigApplicationContext();
TestPropertyValues.of("spring.dao.exceptiontranslation.enabled=false").applyTo(this.context);
TestPropertyValues.of("spring.persistence.exceptiontranslation.enabled=false").applyTo(this.context);
this.context.register(PersistenceExceptionTranslationAutoConfiguration.class);
this.context.refresh();
Map<String, PersistenceExceptionTranslationPostProcessor> beans = this.context
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.domain.scan.a;
package org.springframework.boot.persistence.autoconfigure.scan.a;
import jakarta.persistence.Embeddable;
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.domain.scan.a;
package org.springframework.boot.persistence.autoconfigure.scan.a;
import jakarta.persistence.Entity;
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.domain.scan.b;
package org.springframework.boot.persistence.autoconfigure.scan.b;
import jakarta.persistence.Embeddable;
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.domain.scan.b;
package org.springframework.boot.persistence.autoconfigure.scan.b;
import jakarta.persistence.Entity;
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.domain.scan.c;
package org.springframework.boot.persistence.autoconfigure.scan.c;
import jakarta.persistence.Embeddable;
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.domain.scan.c;
package org.springframework.boot.persistence.autoconfigure.scan.c;
import jakarta.persistence.Entity;
@@ -16,7 +16,7 @@
package org.springframework.boot.test.autoconfigure;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.persistence.autoconfigure.EntityScan;
import org.springframework.boot.test.context.TestConfiguration;
/**
@@ -29,7 +29,7 @@ import org.junit.platform.launcher.core.LauncherFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigurationPackage;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.persistence.autoconfigure.EntityScan;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.boot.test.autoconfigure.orm.jpa.ExampleEntity;
import org.springframework.context.ApplicationContext;
+1 -3
View File
@@ -26,6 +26,7 @@ description = "Spring Boot Transaction"
dependencies {
api(project(":core:spring-boot"))
api(project(":module:spring-boot-persistence"))
api("org.springframework:spring-tx")
optional(project(":core:spring-boot-autoconfigure"))
@@ -36,11 +37,8 @@ dependencies {
testImplementation(project(":test-support:spring-boot-test-support"))
testImplementation("com.github.h-thurow:simple-jndi")
testImplementation("com.zaxxer:HikariCP")
testImplementation("jakarta.persistence:jakarta.persistence-api")
testImplementation("org.hibernate.orm:hibernate-core")
testImplementation("org.hsqldb:hsqldb")
testImplementation("org.springframework:spring-jdbc")
testImplementation("org.springframework:spring-orm")
testRuntimeOnly(project(":module:spring-boot-reactor"))
testRuntimeOnly("ch.qos.logback:logback-classic")
@@ -1,11 +1,5 @@
{
"properties": [
{
"name": "spring.dao.exceptiontranslation.enabled",
"type": "java.lang.Boolean",
"description": "Whether to enable the PersistenceExceptionTranslationPostProcessor.",
"defaultValue": true
},
{
"name": "spring.jta.enabled",
"type": "java.lang.Boolean",
@@ -1,4 +1,3 @@
org.springframework.boot.transaction.autoconfigure.PersistenceExceptionTranslationAutoConfiguration
org.springframework.boot.transaction.autoconfigure.TransactionAutoConfiguration
org.springframework.boot.transaction.autoconfigure.TransactionManagerCustomizationAutoConfiguration
org.springframework.boot.transaction.jta.autoconfigure.JtaAutoConfiguration
+1
View File
@@ -138,6 +138,7 @@ include "module:spring-boot-mustache"
include "module:spring-boot-neo4j"
include "module:spring-boot-netty"
include "module:spring-boot-opentelemetry"
include "module:spring-boot-persistence"
include "module:spring-boot-pulsar"
include "module:spring-boot-quartz"
include "module:spring-boot-r2dbc"