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:39:05 +01:00
parent 2985ff31ac
commit 9a5cd29e3c

View File

@@ -102,8 +102,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);