Alex opened SPR-15352 and commented

When I autowire beans as collection, this beans created by default constructor, but their annotations PostConstract and Autowired don't work.

@Configuration
public class Config
{
    @Bean
    @Autowired
    public SomeBean someBean(Collection<Converter<?, ?>> converters)
    {
       // converters collection contains SomeConverter 
        ...
        return someBean;
    }
}
@Component
public class SomeConverter implements Converter<A, B>
{
    public SomeConverter() {
       // constructor called
    }
    @PostConstruct
    public void init() {
        // PostConstruct not called
    }
    @Autowired
    private SomeOtherBean someOtherBean; // null (not autowired)

    @Override
    public B convert(A source)
    {
        ...
        return target;
    }

}

Affects: 4.3.7

Comment From: spring-projects-issues

Juergen Hoeller commented

The @Autowired annotation on your @Bean method is probably not intended: This turns your factory method into an autowired method that's called during the initialization phase of your configuration class instance, as a sort of setter method (ignoring the returned value).

If you want autowired arguments on your factory method, just declare them (as you already do) and mark the method as @Bean as usual but not as @Autowired at that level.

Comment From: spring-projects-issues

Sergei Ustimenko commented

Juergen Hoeller Maybe it is worth to log it with a warn to highlight that behavior when we have @Bean and @Autowired in the same place might be unintended?

Comment From: sbrannen

Closing outdated, unresolved issues. Please, reopen if still relevant.