如何解决春天的Timer.schedule中的NPE
我在SpringApplication中自动连接了此服务(可运行的实现),并且已正确连接,但是timer.schedule
抛出了一个我不知道的NPE。
这是我的主要方法:
@Autowired
static ExternalDBUpdateThread externalDbUpdateThread;
public static void main(String[] args) {
logger.info("Server is Strating");
context = SpringApplication.run(SprintChatBotApiApplication.class,args);
externalDbUpdateThread = (ExternalDBUpdateThread) context.getBean(ExternalDBUpdateThread.class);
Timer extDbTimer = new Timer();
extDbTimer.schedule(externalDbUpdateThread,Conf.extDbTimeLoop*60000,Conf.extDbTimeLoop*60000);
//the line above throws error,extDbTimer!=null && externalDbUpdateThread!=null
}
这是堆栈跟踪:
Exception in thread "main" java.lang.NullPointerException
at java.util.Timer.sched(Timer.java:399)
at java.util.Timer.schedule(Timer.java:248)
at pl.sprint.chatbot.SprintChatBotApiApplication.main(SprintChatBotApiApplication.java:62)
有什么想法吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。