DATACMNS-1238 - Optimize setting Environment on ClassPathScanningCandidateComponentProvider.

In CustomRepositoryImplementationDetector, we now immediately hand the Environment to the constructor of ClassPathScanningCandidateComponentProvider instead of setting it afterwards. This prevents a default StandardEnvironment from being created in the previously used constructor.
This commit is contained in:
Oliver Gierke
2017-12-30 11:34:51 +01:00
parent d978c9e7b5
commit e7f6c62ca1

View File

@@ -109,8 +109,8 @@ public class CustomRepositoryImplementationDetector {
Pattern pattern = Pattern.compile(".*\\." + className);
// Build classpath scanner and lookup bean definition
ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
provider.setEnvironment(environment);
ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false,
environment);
provider.setResourceLoader(resourceLoader);
provider.setResourcePattern(String.format(CUSTOM_IMPLEMENTATION_RESOURCE_PATTERN, className));
provider.setMetadataReaderFactory(metadataReaderFactory);