Java Notes
Java Notes
Spring Core
Dependency Injection /inversion of control
Without dependency injection , we have to create the objects that we
want in our application using the new keyword.
Class is created
Here, even if we put @Component annotation on the laptop class it does not work without the new keyword because we are not using getBean method. The solution is to use @Autowire annotation
Types of dependency injection
1. Constructor injection Dependency Injection in Spring can be done through
constructors, setters or fields. Interface injection is
2. Setter or field injection not used by spring
3. Interface injection
Agent Cutomer
List of customers Agent FK
List of Orders List of orders FK
FK
Order
Agent FK
Customer FK
FK
2.3 The model, JsonIgnoreProperties
Agent Order
Customer
When you are listing the customer model in agents, you have
to ignore the relationship properties otherwise you will end up
in an infinite loop. For example, every time you place the
customer model class in another class, you have to ignore
agent and orders which are the properties of the customer
model but are by themselves models /classes.
2.3 The model: here are the models
2.3 The model: constructor
• Default constructor is required
• List properties are not included in the constructor
• But objects ( the many side object properties are included)