Demo: wiring Shop Core by hand, then with Spring
On This Lesson 3 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
move Shop Core from manual new to Spring beans; prepares JNR-009-LAB1.
Draft outline details
Step by step
- Show
mainbuildingPricingService,PaymentProvider, andOrderServicewithnew. - Annotate the services with
@Serviceand keep constructor parameters. - Delete the
newcalls frommain; run the Boot app. - Planned mistake: put
@Autowiredon a field and write a unit test withnew OrderService(...); the field is null and the test fails. Fix: switch to constructor injection. - Show that the unit test now passes a fake
PaymentProvider.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.