[英]Spring - how to rename @Bean
How do you define an annotation in Spring that is semantically equivalent to @Bean
, but has another name? 如何在Spring中定义一个在语义上等效于
@Bean
却具有另一个名称的注释?
(Why? I'm building a DSL in which the functionality would fit, but it would greatly benefit from naming the annotation more closely to the role it plays in the library). (为什么?我正在构建适合其功能的DSL,但是通过更紧密地将注释命名为它在库中所扮演的角色,这将大有裨益)。
Well... It was as easy as: 嗯...很简单:
@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Bean
public @interface CustomAnnotation {
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.