I tried using @Named
annotation on methods that create a bean, but that doesn't seem to work. Couldn't find any question here or a blog that confirms this. Reading the description at jcp.org, I don't see any relationship b/w beans and dependency injection introduced by JSR-330 either: https://jcp.org/en/jsr/detail?id=330
No, JSR-330 does not have the equivalent of Spring's @Bean
or Guice's @Provides
annotations.
There are only 5 annotations in JSR-330, and they are equivalent to the following Spring1 / Guice2 annotations:
JSR-330 Spring Guice
---------- ------------------- ------------------
@Inject @Autowired @Inject
@Named @Component @Named
@Qualifier @Qualifier @BindingAnnotation
@Scope @Scope @ScopeAnnotation
@Singleton @Scope("singleton") @Singleton
- @Scope("prototype") -
1) From Using JSR 330 Standard Annotations and Using JSR 330 Standard Annotations
2) From JSR-330 Integration
They do not match up exactly, so read the articles listed in the footnotes for full detail.