1. Null pointer exception:
Request processing failed; nested exception is java.lang.NullPointerException
java.lang.NullPointerException
com.atguigu.mvc.controller.NodesController.getFilesAndSendId(NodesController.java:61)
See the exception address and check the control layer
Control level, line 61:
List<FilePath> files = fileService.getFiles();
current
@RequestMapping(value = "/getFilesAndSendId/{sensor_id}",method = RequestMethod.GET)
Parameter sensor_id is passed;
Solution to null pointer:
Original:
private FileService fileService;
Change to: add @Autowired annotation
@Autowired
private FileService fileService;
If there is any other error when you run the codes:
Servlet.init() of Servlet[DispatcherServlet] raises an exception.
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘nodesController’: Unsatisfied dependency expressed through field ‘fileService’; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.atguigu.mvc.service.FileService’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
Solution:
Check if the @Service annotation is added to the implementation class here