Request processing failed; nested exception is java.lang.NullPointerException或UnsatisfiedDependencyE

1.空指针异常
Request processing failed; nested exception is java.lang.NullPointerException

java.lang.NullPointerException
com.atguigu.mvc.controller.NodesController.getFilesAndSendId(NodesController.java:61)
在这里插入图片描述
看到异常地址,检查控制层
在这里插入图片描述
控制层第61行:

List<FilePath> files = fileService.getFiles();

当前

@RequestMapping(value = "/getFilesAndSendId/{sensor_id}",method = RequestMethod.GET)

传入了参数sensor_id;

解决空指针方案:
原来的:

private FileService fileService;

改成:即添加@Autowired注解

 @Autowired
    private FileService fileService;

运行代码,如果接着报错:
Servlet[DispatcherServlet]的Servlet.init()引发异常;

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)}
在这里插入图片描述
解决办法:
检查此处实现类是否添加了@Service注解
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值