Yanming Zhou opened SPR-16066 and commented
@Service
is a specialization of @Component
, like @GetMapping
is a specialization of @RequestMapping
, @Service
should add @AliasFor
like @GetMapping
@Component
public @interface Service
{
@AliasFor(annotation=Component.class)
String value() default "";
}
We can get metadata from annotation via unified code
Component component = AnnotatedElementUtils.getMergedAnnotation(clazz, @Component.class);
String beanName = component.value();
Referenced from: commits https://github.com/spring-projects/spring-framework/commit/43b5e21947f3ad9682ae39cd8b8b5ae4b8f72c14, https://github.com/spring-projects/spring-framework/commit/625737f90ad07b08a301252a8b5a4d2f8652817d
Comment From: spring-projects-issues
Sam Brannen commented
Juergen Hoeller, any reason not to apply the same change to annotations such as @Configuration
, @RestController
, @ControllerAdvice
, @RestControllerAdvice
, etc.?
Comment From: spring-projects-issues
Juergen Hoeller commented
Good point :-) I've added similar declarations to @Configuration
and @RestController
(with the alias pointing to @Controller
in the latter case). The controller advices don't have a value attribute with bean name semantics, so don't seem applicable here.
Comment From: spring-projects-issues
Sam Brannen commented
I've added similar declarations to
@Configuration
and@RestController
(with the alias pointing to@Controller
in the latter case).
Cool. Thanks!
The controller advices don't have a value attribute with bean name semantics, so don't seem applicable here.
MMmmmmmm... indeed. I just listed off stereotypes without actually checking the source code. ;-)