Grokking Spring Boot
0% completed
Conditional Beans
@Component @Profile("dev") public class FakePaymentClient implements PaymentClient { private int calls = 0; public FakePaymentClient() { log.info("FakePaymentClient: every charge will be approved, no money moves"); } @Override public PaymentResult charge(String customerEmail, int amountInCents) { calls++; return new PaymentResult(true, "fake-" + calls); } } @Component @Profile("!dev") public class HttpPaymentClient implements PaymentClient { ... }
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%