I'm working on a class that has the following:
@Bean(name = "pluto")
public Z potato (...) {
...
}
@Bean(name = "mars")
public carrot (@Named("pluto") Z z) {
...
}
I'd like to know if @Bean
and @Named
are interchangeable.
Also, why is @Named
being used in the parameter?
@Makoto, @Named annotation in Spring MVC is similar but the answer here seems to be
@Named
and@Bean
are equivalent, but are from different APIs. So only use@Named
for consistency