是否有等效于 Spring 的 @Bean 或 Guice 的 @Provides 注释的 JSR-330?
Is there a JSR-330 equivalent of Spring's @Bean or Guice's @Provides annotation?
我尝试在创建 bean 的方法上使用 @Named
注释,但这似乎不起作用。在这里找不到任何问题或证实这一点的博客。阅读 jcp.org 的描述,我没有看到任何关系 b/w bean 和 JSR-330 引入的依赖注入:https://jcp.org/en/jsr/detail?id=330
不,JSR-330 没有相当于 Spring 的 @Bean
或 Guice 的 @Provides
注释。
JSR-330中只有5个注解,相当于下面的Spring1 / Guice2 注释:
JSR-330 Spring Guice
---------- ------------------- ------------------
@Inject @Autowired @Inject
@Named @Component @Named
@Qualifier @Qualifier @BindingAnnotation
@Scope @Scope @ScopeAnnotation
@Singleton - @Singleton
- @Scope("prototype") -
1) 来自Using JSR 330 Standard Annotations and Using JSR 330 Standard Annotations
2) 来自JSR-330 Integration
它们并不完全匹配,因此请阅读脚注中列出的文章以获取完整的详细信息。
我尝试在创建 bean 的方法上使用 @Named
注释,但这似乎不起作用。在这里找不到任何问题或证实这一点的博客。阅读 jcp.org 的描述,我没有看到任何关系 b/w bean 和 JSR-330 引入的依赖注入:https://jcp.org/en/jsr/detail?id=330
不,JSR-330 没有相当于 Spring 的 @Bean
或 Guice 的 @Provides
注释。
JSR-330中只有5个注解,相当于下面的Spring1 / Guice2 注释:
JSR-330 Spring Guice
---------- ------------------- ------------------
@Inject @Autowired @Inject
@Named @Component @Named
@Qualifier @Qualifier @BindingAnnotation
@Scope @Scope @ScopeAnnotation
@Singleton - @Singleton
- @Scope("prototype") -
1) 来自Using JSR 330 Standard Annotations and Using JSR 330 Standard Annotations
2) 来自JSR-330 Integration
它们并不完全匹配,因此请阅读脚注中列出的文章以获取完整的详细信息。