Posts

Autowired in Spring Boot

Image
                                  Autowired in Spring Boot Keyword : @Autowired byName byType constructor setter @Qualifier Custom Qualifier annotation @Primary JSR-250 Annotation : @Resource JSR-330 Annotation : @Inject Dependancies : web , lombok ,  ## byType : It basically check the type . If the type is matched with service then it automatically create the bean. CarController.java package com.vrushant.AutowiredInSpringBoot.controller ; @RestController @RequestMapping ( "/cars" ) public class CarController { @Autowired private Car car ; // By Type @GetMapping public String drive (){ return car .drive() ; } } Car.java interface package com.vrushant.AutowiredInSpringBoot ; public interface Car { String drive () ; } SedanCar.java Service package com.vrushant.AutowiredInSpringBoot ; import org.springframework.stereotype. Servic...