Dependency injection and the bean scope

We understand each scope has a different boundary. Now, we will write one REST controller to understand how different scope beans are injected to other reference beans by writing simple Spring boot applications. 

In the following diagram, the StudentController has injected the reference to all other classes. The ClassDetail class with the session scope has two references to singleton and prototype, and the student application contains a few other associations between classes as well. Autowired annotation is utilized to fulfill dependency between beans. Just to clarify, Spring controllers are always created with the singleton scope:

As we are writing a Spring boot application with REST. Will will have ...

Get Java 9 Dependency Injection now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.