在blade-user模块上新增配置类跑定时任务,注入的userMapper在服务器上跑报空指针异常

Blade 未结 2 1198
jse7en
jse7en 2021-03-23 10:52
悬赏:5

一、该问题的重现步骤是什么?

  1. 新增配置类,并注入userMapper.

image.png

2. 启动定时任务,执行对应方法

image.png

image.png


二、你期待的结果是什么?实际看到的又是什么?

测试邮件能顺利发送成功;调用userMapper的方法报错空指针异常。

三、你正在使用的是什么产品,什么版本?在什么操作系统上?

2.7 bladex ,springcloud版本,在centos7上

四、请提供详细的错误堆栈信息,这很重要。

2021-03-23 10:52:00.652 ERROR 30704 --- [sync-scheduler1] o.s.c.b.c.BladeExecutorConfiguration     : Unexpected scheduler exception


java.lang.NullPointerException: null

at org.springblade.system.user.config.EmailTimingConfiguration.scheduleTestSendEmail(EmailTimingConfiguration.java:104)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84)

at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)

at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:93)

at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)

at java.util.concurrent.FutureTask.run(FutureTask.java:266)

at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)

at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)

at java.lang.Thread.run(Thread.java:748)

五、若有更多详细信息,请在下面提供。

2条回答
  •  morin
    morin (楼主)
    2021-03-23 16:58

    EmailTimingConfiguration.java:104行空了,说明你103行seleceOne()没有查到user对象,user是null吧

提交回复