Reintroduce component index support for Jakarta annotations
Spring Framework 6.0 GA introduced a regression in the component index support for Jakarta annotations such as @Named and @ManagedBean. Prior to this commit, @Named and @ManagedBean components were registered in the component index at build time; however, component scanning failed to find those component at run time. This commit updates ClassPathScanningCandidateComponentProvider so that `jakarta.*` annotation types are once again supported for component scanning via the component index at run time. Closes gh-29641
This commit is contained in:
@@ -79,6 +79,7 @@ import org.springframework.util.ClassUtils;
|
||||
* @author Ramnivas Laddad
|
||||
* @author Chris Beams
|
||||
* @author Stephane Nicoll
|
||||
* @author Sam Brannen
|
||||
* @since 2.5
|
||||
* @see org.springframework.core.type.classreading.MetadataReaderFactory
|
||||
* @see org.springframework.core.type.AnnotationMetadata
|
||||
@@ -343,7 +344,7 @@ public class ClassPathScanningCandidateComponentProvider implements EnvironmentC
|
||||
if (filter instanceof AnnotationTypeFilter annotationTypeFilter) {
|
||||
Class<? extends Annotation> annotationType = annotationTypeFilter.getAnnotationType();
|
||||
return (AnnotationUtils.isAnnotationDeclaredLocally(Indexed.class, annotationType) ||
|
||||
annotationType.getName().startsWith("javax."));
|
||||
annotationType.getName().startsWith("jakarta."));
|
||||
}
|
||||
if (filter instanceof AssignableTypeFilter assignableTypeFilter) {
|
||||
Class<?> target = assignableTypeFilter.getTargetType();
|
||||
|
||||
Reference in New Issue
Block a user