Where is the @Autowired annotation supposed to go – on the property or the method?
According to the Javadoc for Autowired, the annotation can be used on “a constructor, field, setter method or config method”. See the full documentation for more details. I personally prefer your first option (constructor injection), because the myDao field can be marked as final: @Controller public class MyControllear { private final MyDao myDao; @Autowired public … Read more