May 2019
Intermediate to advanced
316 pages
7h 13m
English
Spring Boot scans your application classes and register classes with certain annotations (@Service, @Repository, @Controller) as Spring Beans. These beans can then be injected using an @Autowired annotation:
public class Car { @Autowired private Owner owner; ...}
A fairly common situation is where we need database access for some operations, and, in Spring Boot, we are using repository classes for that. In this situation, we can inject repository class and start to use its methods:
public class Car { @Autowired private CarRepository carRepository; // Fetch all cars from db carRepositoty.findAll(); ...}
Java (javax.annotation) also provides a @Resource annotation that can be used to inject resources. You can define the ...
Read now
Unlock full access