spring-in-action-5-samples icon indicating copy to clipboard operation
spring-in-action-5-samples copied to clipboard

Autowired@ needed ?

Open aCodeRancher opened this issue 6 years ago • 2 comments

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

aCodeRancher avatar Jan 24 '19 20:01 aCodeRancher

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.

Sammygracezhu avatar Aug 14 '19 16:08 Sammygracezhu

established by usage

TsinghuaDream avatar Mar 12 '20 23:03 TsinghuaDream