Spring Boot - Inversion of Control and Dependency Injection
You have a Spring Boot service class that uses field injection:
How would switching to constructor injection improve this class?
public class OrderService {
@Autowired
private PaymentService paymentService;
public boolean processOrder(Order order) {
return paymentService.charge(order.getAmount());
}
}How would switching to constructor injection improve this class?
