Yes, the example is correct (starting with Spring 4.3). According to the documentation ( this for ex), if the bean has a single constructor, the @Autowired annotation may be omitted.
But there are several nuances:
1. If there is only one constructor, and the installer is marked with @Autowired annotation, then both the installation of the constructor and the installation will be performed one after another:
@Component public class TwoInjectionStyles { private Foo foo; public TwoInjectionStyles(Foo f) { this.foo = f;
2. On the other hand, if there is no @Autowire at all (as in your example ), than f object will be entered once through the constructor, and the setter can be used in it in the usual way without any injections.
source share