DATACMNS-1596 - Modules not exposing identifying annotations do not claim repository interfaces anymore.
Previously, a module not exposing any entity identifying annotations would have claimed a repository definition and potentially overrode the bean definition of another store that was the proper claim in the first place. We have now changed this to abstain from a claim of the interface. We' also tweaked the log output in the following cases: 1. If the module neither returns an identifying type nor entity identifying annotations, we now log a warning that a module does not support a multi-module setup and answer all assignment requests with false. 2. The info level warning indicating an interface has been dropped now reports which annotations or interface base types to use. Original pull request: #411. Related tickets: spring-projects/spring-boot#18721
This commit is contained in:
committed by
Mark Paluch
parent
373eccda8a
commit
8bb87a1749
@@ -34,9 +34,11 @@ import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
import org.springframework.core.type.StandardAnnotationMetadata;
|
||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.data.repository.core.RepositoryMetadata;
|
||||
import org.springframework.data.repository.core.support.AbstractRepositoryMetadata;
|
||||
import org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport;
|
||||
import org.springframework.data.repository.core.support.RepositoryFactorySupport;
|
||||
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
|
||||
|
||||
@@ -86,6 +88,15 @@ public class RepositoryConfigurationExtensionSupportUnitTests {
|
||||
.hasMessageContaining("Reactive Repositories are not supported");
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1596
|
||||
public void doesNotClaimEntityIfNoIdentifyingAnnotationsAreExposed() {
|
||||
|
||||
NonIdentifyingConfigurationExtension extension = new NonIdentifyingConfigurationExtension();
|
||||
RepositoryMetadata metadata = AbstractRepositoryMetadata.getMetadata(AnnotatedTypeRepository.class);
|
||||
|
||||
assertThat(extension.isStrictRepositoryCandidate(metadata)).isFalse();
|
||||
}
|
||||
|
||||
static class SampleRepositoryConfigurationExtension extends RepositoryConfigurationExtensionSupport {
|
||||
|
||||
@Override
|
||||
@@ -109,6 +120,24 @@ public class RepositoryConfigurationExtensionSupportUnitTests {
|
||||
}
|
||||
}
|
||||
|
||||
static class NonIdentifyingConfigurationExtension extends RepositoryConfigurationExtensionSupport {
|
||||
|
||||
@Override
|
||||
protected String getModulePrefix() {
|
||||
return "non-identifying";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRepositoryFactoryBeanClassName() {
|
||||
return RepositoryFactoryBeanSupport.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<Class<?>> getIdentifyingTypes() {
|
||||
return Collections.singleton(CrudRepository.class);
|
||||
}
|
||||
}
|
||||
|
||||
@Primary
|
||||
static class AnnotatedType {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user