1. 程式人生 > >java.lang.NullPointerException 空指標異常問題

java.lang.NullPointerException 空指標異常問題

初學者的我在使用springmvc+mybatis時被這問題搞了2小時

百度的問題也都試著追蹤了,發現了問題但是無法解決

 private CustomerService customerService;

  @RequestMapping("/list")
  public String list()
    throws Exception
  {
    List<BaseDict> list = customerService.findSearchParamera("009");
    System.out.println("customerService================" + customerService);
    return "customer";
  }
列印customerService發現為null。

類也匯入了,各方面都沒問題 為何是null呢。

最後掙扎半天發現了  犯了一個很“腦殘”的錯誤

沒有在private CustomerService customerService; 上面增加註解@Autowired

鬱悶