I'm trying to understand the following code
@Bean
@ConditionalOnMissingBean(name = "monitor")
@ConditionalOnBean(name={"identity"})
@Autowired
public MyObject myObject(@Qualifier("identity") Identity identity) {
return new MyObject(clientFactory);
}
What purpose does @Autowired serve?
To my mind it seems redundant. At a guess the writer might believe it required to support the Identity injection. But, AFAIK, @Bean will do that.
----Edit----
Might need to mention that the example I've seen before is inside a @Configuration class.
@Bean
public AnotherObject anotherObject(Environment env) {
return new AnotherObject(env);
}