1. 程式人生 > >Field userService in com.wuji.controller.UserController required a bean of type 'com.wuji.service.UserService' that could not be found

Field userService in com.wuji.controller.UserController required a bean of type 'com.wuji.service.UserService' that could not be found

Field userService in com.wuji.controller.UserController required a bean of type 'com.wuji.service.UserService' that could not be found.

原因:說明IOC裡沒有建立Bean,在啟動檔案上手動新增:@ComponentScan(basePackages = {"com.wuji"})註解開啟Spring元件掃描