Spring
@Autowired
As of Spring Framework 4.3, an
@Autowired
annotation on such a constructor is no longer necessary if the target bean defines only one constructor to begin with. However, if several constructors are available, at least one must be annotated to teach the container which one to use.
public class MovieRecommender { private final CustomerPreferenceDao customerPreferenceDao; // @Autowired public MovieRecommender(CustomerPreferenceDao customerPreferenceDao) { this.customerPreferenceDao = customerPreferenceDao; } }