使用spring的@Scheduled实现定时任务功能,运行时报错

Scheduled 是异步起线程来处理你的逻辑的
但你配置了 LogIntercept 这个拦截器, 里面的54行中, 会去调用RequestContextHolder.currentRequestAttributes, 但这个方法是需要有 http request 和 response 绑定到当前的线程中的.
由于你是使用的异步线程, 当然没有这个绑定了.
所以这个设计是有问题的. 不要在定时任务中使用 http request 和 response.

posted @ 2017-07-28 09:22  11cnblogs  阅读(700)  评论(0编辑  收藏  举报