@Autowired
@Autowired
@Autowired
is used for automatic dependency injection in Spring. It can be applied to constructors, methods, and fields@Component public class MyService { @Autowired private MyRepository myRepository; }
Use
@Autowired
with@Qualifier
can specify which implementation to injectUse
@Primary
with@Component
can set that implementation as default bean