Cron expression must consist of 6 fields (found 7 in "0 * * * * ? *")
Posted daopinz
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Cron expression must consist of 6 fields (found 7 in "0 * * * * ? *")相关的知识,希望对你有一定的参考价值。
在SpringBoot上写一个定时器,要求,一个小时执行一次,BUT。。。
Initialization of bean failed; nested exception is java.lang.IllegalStateException: Encountered invalid @Scheduled method 'Timer': Cron expression must consist of 6 fields (found 7 in "0 * * * * ? *")
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:564)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
写上去之后,直接给启动失败了,额额额,看报错的意思是,只能是6位的,而我写了7位,查了资料后,有网友说,最后一位表示的年,1099~2099年,可以省略不写,果断把最后一个星号“ * ”,去掉后,就可以啦,嘿嘿嘿,又涨姿势啦!
以上是关于Cron expression must consist of 6 fields (found 7 in "0 * * * * ? *")的主要内容,如果未能解决你的问题,请参考以下文章
解决find命令报错: paths must precede expression
解决find命令报错: paths must precede expression
django1.11 启动错误:Generator expression must be parenthesized