spring - Cron expression must consist of 6 fields (found 1 in "#{systemEnvironment['db_cron']}") -


i'm trying set cron scheduled annotation follows:

@scheduled(cron = "#{systemenvironment['db_cron']}") def void schedule() {  } 

next set environment variable as:

export db_cron="0 19 21 * * *" 

however, runtime error:

cron expression must consist of 6 fields    (found 1 in "#{systemenvironment['db_cron']}") 

what can going wrong?


edit

i have tried: @scheduled(cron = "${db_cron}")

but returns compile time error:

/users/snowch/repos/sales/prospects/snow/plugwise/etl_service/src/main/groovy/com/ibm/etl/application.groovy: 52: expected '$db_cron' inline constant of type java.lang.string in @org.springframework.scheduling.annotation.scheduled  @ line 52, column 23.        @scheduled(cron = "${db_cron}")                          ^  /users/snowch/repos/sales/prospects/snow/plugwise/etl_service/src/main/groovy/com/ibm/etl/application.groovy: -1: attribute 'cron' should have type 'java.lang.string'; found type 'java.lang.object' in @org.springframework.scheduling.annotation.scheduled  @ line -1, column -1. 2 errors  :compilegroovy failed  failure: build failed exception. 

i have tried @scheduled(cron = "#{db_cron}")

but runtime error was:

exception in thread "main" groovy.lang.missingmethodexception: no signature of method: static org.springframework.beans.factory.config.propertyplaceholderconfigurer.setsystempropertiesmode() applicable argument types: (java.lang.integer) values: [2] possible solutions: setsystempropertiesmode(int), setsystempropertiesmodename(java.lang.string)     @ groovy.lang.metaclassimpl.invokestaticmissingmethod(metaclassimpl.java:1373)     @ groovy.lang.metaclassimpl.invokestaticmethod(metaclassimpl.java:1359)     @ org.codehaus.groovy.runtime.callsite.staticmetaclasssite.call(staticmetaclasssite.java:50)     @ org.codehaus.groovy.runtime.callsite.callsitearray.defaultcall(callsitearray.java:45)     @ org.codehaus.groovy.runtime.callsite.abstractcallsite.call(abstractcallsite.java:108)     @ org.codehaus.groovy.runtime.callsite.abstractcallsite.call(abstractcallsite.java:116)     @ com.ibm.etl.application.main(application.groovy:43) 

note environment variable set follows:

snowch$ echo "$db_cron" 0 19 21 * * * 

you should set env variable do:

export db_cron="0 19 21 * * *" 

then restart ide if using or restart terminal session.

@scheduled(cron = "${db_cron}") def void schedule() {    ... } 

i tried , here screenshot. works expected...cron expression env variable


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -