29
29
import org .springframework .aot .hint .MemberCategory ;
30
30
import org .springframework .aot .hint .ReflectionHints ;
31
31
import org .springframework .aot .hint .TypeReference ;
32
+ import org .springframework .beans .factory .annotation .AnnotatedBeanDefinition ;
32
33
import org .springframework .beans .factory .aot .BeanFactoryInitializationAotContribution ;
33
34
import org .springframework .beans .factory .aot .BeanFactoryInitializationAotProcessor ;
34
35
import org .springframework .beans .factory .config .BeanDefinition ;
@@ -84,7 +85,7 @@ public BeanFactoryInitializationAotContribution processAheadOfTime(ConfigurableL
84
85
85
86
private static Set <Class <?>> getTypesToRegister (String packageName ) {
86
87
Set <Class <?>> classesToAdd = new HashSet <>();
87
- ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider ( false );
88
+ ClassPathScanningCandidateComponentProvider provider = buildProvider ( );
88
89
provider .addIncludeFilter (new AssignableTypeFilter (Object .class ));
89
90
Set <BeanDefinition > components = provider .findCandidateComponents (packageName );
90
91
for (BeanDefinition component : components ) {
@@ -104,6 +105,17 @@ private static Set<Class<?>> getTypesToRegister(String packageName) {
104
105
return classesToAdd ;
105
106
}
106
107
108
+ private static ClassPathScanningCandidateComponentProvider buildProvider () {
109
+ return new ClassPathScanningCandidateComponentProvider (false ) {
110
+ @ SuppressWarnings ("NullableProblems" )
111
+ @ Override
112
+ protected boolean isCandidateComponent (AnnotatedBeanDefinition beanDefinition ) {
113
+ // Include both concrete classes and interfaces
114
+ return beanDefinition .getMetadata ().isIndependent () && !beanDefinition .getMetadata ().isAnnotation ();
115
+ }
116
+ };
117
+ }
118
+
107
119
private static boolean shouldRegisterClass (Class <?> clazz ) {
108
120
Set <String > conditionClasses = beansConditionalOnClasses .getOrDefault (clazz .getName (), Collections .emptySet ());
109
121
for (String conditionClass : conditionClasses ) {
0 commit comments