1@Service
2public class InvoiceService {
3 @Autowired
4 private PricingClient pricingClient;
5
6 public double getTotal(Order order) {
7 return pricingClient.calculate(order);
8 }
9}
10
11public class InvoiceRunner {
12 public static void main(String[] args) {
13 InvoiceService service = new InvoiceService();
14 service.getTotal(new Order());
15 }
16}
no lines flagged
#062PracticeEasy10 min · 50 XP
Autowired Field Null Outside Spring Container
A utility class manually instantiated with new throws a NullPointerException on its @Autowired dependency.
Flagged linesNo lines flagged yet
What's wrong?
Flag a line or write a note to submit.