diff --git a/src/main/java/org/springframework/data/repository/core/support/RepositoryFactoryBeanSupport.java b/src/main/java/org/springframework/data/repository/core/support/RepositoryFactoryBeanSupport.java index 4dca9e724..c8c0f1d8b 100644 --- a/src/main/java/org/springframework/data/repository/core/support/RepositoryFactoryBeanSupport.java +++ b/src/main/java/org/springframework/data/repository/core/support/RepositoryFactoryBeanSupport.java @@ -34,6 +34,7 @@ import org.springframework.context.ApplicationEventPublisherAware; import org.springframework.context.EnvironmentAware; import org.springframework.context.aot.AbstractAotProcessor; import org.springframework.core.env.Environment; +import org.springframework.core.io.support.SpringFactoriesLoader; import org.springframework.data.mapping.PersistentEntity; import org.springframework.data.mapping.context.MappingContext; import org.springframework.data.projection.ProjectionFactory; @@ -260,8 +261,7 @@ public abstract class RepositoryFactoryBeanSupport, @Override @SuppressWarnings("unchecked") public EntityInformation getEntityInformation() { - return (EntityInformation) getRequiredFactory() - .getEntityInformation(getRequiredRepositoryMetadata()); + return (EntityInformation) getRequiredFactory().getEntityInformation(getRequiredRepositoryMetadata()); } @Override @@ -341,6 +341,14 @@ public abstract class RepositoryFactoryBeanSupport, this.factory.setRepositoryBaseClass(repositoryBaseClass); } + SpringFactoriesLoader.loadFactories(RepositoryFactoryCustomizer.class, classLoader).forEach(customizer -> { + + if (!(customizer instanceof ConditionalRepositoryFactoryCustomizer conditional) + || conditional.canCustomize(this.factory, this.repositoryInterface)) { + customizer.customize(this.factory); + } + }); + if (beanFactory != null) { beanFactory.getBeanProvider(TypedRepositoryFactoryCustomizer.class).orderedStream().forEachOrdered(customizer -> { @@ -401,8 +409,7 @@ public abstract class RepositoryFactoryBeanSupport, RepositoryFragments fragments = RepositoryFragments.empty(); for (RepositoryFragmentsFunction function : functions) { - fragments = fragments.append(function.getRepositoryFragments(this.beanFactory, - creationContext)); + fragments = fragments.append(function.getRepositoryFragments(this.beanFactory, creationContext)); } return fragments; @@ -426,8 +433,7 @@ public abstract class RepositoryFactoryBeanSupport, * @param context the creation context. * @return the repository fragments to use. */ - RepositoryFragments getRepositoryFragments(@Nullable BeanFactory beanFactory, - FragmentCreationContext context); + RepositoryFragments getRepositoryFragments(@Nullable BeanFactory beanFactory, FragmentCreationContext context); /** * Factory method to create {@link RepositoryFragmentsFunction} for a resolved {@link RepositoryFragments} object.