spring 新手的错误,老手可以走开了,不浪费你的时间
产生的原因,自己实例化了对象A,而对象A中有成员变量B使用了注解 @AutoWired
示例:
service 中有 @AutoWired

在localService 中自己实例化了服务,会报成员变量空指针,说fundDailyMapper 空指针。

解决办法是先看 你的成员变量的类是在包的扫描范围不,然后服务不要自己new,要用@AutoWired
spring 新手的错误,老手可以走开了,不浪费你的时间
产生的原因,自己实例化了对象A,而对象A中有成员变量B使用了注解 @AutoWired
示例:
service 中有 @AutoWired
在localService 中自己实例化了服务,会报成员变量空指针,说fundDailyMapper 空指针。
解决办法是先看 你的成员变量的类是在包的扫描范围不,然后服务不要自己new,要用@AutoWired
本文标题:spring boot 成员变量空指针问题
本文链接:https://www.haomeiwen.com/subject/gqkjdctx.html
网友评论