Grokking Spring Boot
0% completed
Component Classes and Bean Methods
Two beans in the booking service reach the container by different routes. SeatRepository carries an annotation on its own class.
@Repository public class SeatRepository { private final Map<String, String> holders = new HashMap<>(); // isFree and reserve }
PaymentClient carries no annotation at all. A method in another class creates it instead.
@Bean public PaymentClient paymentClient() { return new PaymentClient("https://payments.example.com", Duration.ofSeconds(2), retryPolicy()); }
Both end up as singletons in the same context
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%