File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
spring-modulith-test/src/main/java/org/springframework/modulith/test Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -293,13 +293,26 @@ private static Class<?> findSpringBootApplicationByClasses(ApplicationModuleTest
293293
294294 var types = ObjectUtils .addObjectToArray (annotation .classes (), testClass );
295295
296- return Arrays .stream (types )
297- .<Class <?>> map (ModuleTestExecution ::lookupSpringBootApplicationAnnotation )
298- .findFirst ()
296+ return findClassAnnotatedWithAtSpringBoot (types )
297+ .or (() -> scanForClassAnnotatedWithSpringBoot (types ))
299298 .orElseThrow (() -> new IllegalStateException ("Couldn't find @SpringBootApplication traversing %s."
300299 .formatted (Arrays .stream (types ).map (Class ::getName ).collect (Collectors .joining (", " )))));
301300 }
302301
302+ private static Optional <Class <?>> findClassAnnotatedWithAtSpringBoot (Class <?>[] candidates ) {
303+
304+ return Arrays .stream (candidates )
305+ .filter (it -> AnnotatedElementUtils .hasAnnotation (it , SpringBootApplication .class ))
306+ .findFirst ();
307+ }
308+
309+ private static Optional <Class <?>> scanForClassAnnotatedWithSpringBoot (Class <?>[] candidates ) {
310+
311+ return Arrays .stream (candidates )
312+ .<Class <?>> map (ModuleTestExecution ::lookupSpringBootApplicationAnnotation )
313+ .findFirst ();
314+ }
315+
303316 private static Class <?> lookupSpringBootApplicationAnnotation (Class <?> clazz ) {
304317
305318 return MODULITH_TYPES .computeIfAbsent (clazz ,
You can’t perform that action at this time.
0 commit comments