@@ -87,7 +87,8 @@ public <T extends RepositoryConfigurationSource> Collection<RepositoryConfigurat
87
87
for (BeanDefinition candidate : configSource .getCandidates (loader )) {
88
88
89
89
RepositoryConfiguration <T > configuration = getRepositoryConfiguration (candidate , configSource );
90
- Class <?> repositoryInterface = loadRepositoryInterface (configuration , loader );
90
+ Class <?> repositoryInterface = loadRepositoryInterface (configuration ,
91
+ getConfigurationInspectionClassLoader (loader ));
91
92
92
93
if (repositoryInterface == null ) {
93
94
result .add (configuration );
@@ -113,6 +114,19 @@ public <T extends RepositoryConfigurationSource> Collection<RepositoryConfigurat
113
114
return result ;
114
115
}
115
116
117
+ /**
118
+ * Returns the {@link ClassLoader} to load repository interfaces for configuration inspection. Subclasses may override
119
+ * this method to provide a customized class loader.
120
+ *
121
+ * @param loader must not be {@literal null}.
122
+ * @return the {@link ClassLoader} for repository interfaces configuration inspection.
123
+ * @since 2.1
124
+ */
125
+ @ Nullable
126
+ protected ClassLoader getConfigurationInspectionClassLoader (ResourceLoader loader ) {
127
+ return loader .getClassLoader ();
128
+ }
129
+
116
130
/*
117
131
* (non-Javadoc)
118
132
* @see org.springframework.data.repository.config.RepositoryConfigurationExtension#getDefaultNamedQueryLocation()
@@ -297,17 +311,16 @@ protected boolean useRepositoryConfiguration(RepositoryMetadata metadata) {
297
311
298
312
/**
299
313
* Loads the repository interface contained in the given {@link RepositoryConfiguration} using the given
300
- * {@link ResourceLoader }.
314
+ * {@link ClassLoader }.
301
315
*
302
316
* @param configuration must not be {@literal null}.
303
- * @param loader must not be {@literal null}.
317
+ * @param classLoader must not be {@literal null}.
304
318
* @return the repository interface or {@literal null} if it can't be loaded.
305
319
*/
306
320
@ Nullable
307
- private Class <?> loadRepositoryInterface (RepositoryConfiguration <?> configuration , ResourceLoader loader ) {
321
+ private Class <?> loadRepositoryInterface (RepositoryConfiguration <?> configuration , ClassLoader classLoader ) {
308
322
309
323
String repositoryInterface = configuration .getRepositoryInterface ();
310
- ClassLoader classLoader = loader .getClassLoader ();
311
324
312
325
try {
313
326
return org .springframework .util .ClassUtils .forName (repositoryInterface , classLoader );
0 commit comments