Spring beans & @Autowired
Në shqip: Bean-et e Spring-ut
ShpjegimiSQ
Spring-u i krijon vetë objektet e aplikacionit („beans“) dhe ia jep secilit atë që i duhet përmes konstruktorit — kjo është dependency injection. Ti thjesht shënon klasat me @Service ose @Component.
EnglishEN
Spring creates the app's objects (“beans”) itself and gives each one what it needs through its constructor — that's dependency injection. You just mark classes with @Service or @Component.
Si ta mendosh
Si kuzhinieri që i gjen përbërësit gati në tavolinë, pa shkuar vetë në treg.
Lexoje në anglisht
Like a chef who finds ingredients ready on the table without going to the market.
Shembull kodijava
@Service
class TermaService {
private final TermaRepository repo;
TermaService(TermaRepository repo) { this.repo = repo; } // injektohet vetë
}