habuma / spring-in-action-5-samples

Home for example code from Spring in Action 5.
Apache License 2.0
1.21k stars 1.04k forks source link

Autowired@ needed ? #36

Open aCodeRancher opened 5 years ago

aCodeRancher commented 5 years ago

Is @Autowired missing here in OrderController's constructor in chapter 3 example? public OrderController(OrderRepository orderRepo) { this.orderRepo = orderRepo; }

Sammygracezhu commented 5 years ago

As of Spring Framework 4.3, an @Autowired annotation on such a constructor is no longer necessary if the target bean only defines 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.

TsinghuaDream commented 4 years ago

established by usage