Skip to content
Ameen Abozaid
Planned lessonJNR-009-L07

Demo: wiring Shop Core by hand, then with Spring

  • Lesson 7 of 8
  • Junior
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

  1. Show main building PricingService, PaymentProvider, and OrderService with new.
  2. Annotate the services with @Service and keep constructor parameters.
  3. Delete the new calls from main; run the Boot app.
  4. Planned mistake: put @Autowired on a field and write a unit test with new OrderService(...); the field is null and the test fails. Fix: switch to constructor injection.
  5. Show that the unit test now passes a fake PaymentProvider.

Practice

Apply this lesson with the module's lab, exercises and quiz.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Continue to next lesson

Type to search levels, phases, modules and lessons.