title: Cron expression must consist of 6 fields (found 1 in "#{systemEnvironment['db_cron']}")
body: <p>I'm trying to set a cron Scheduled annotation as follows:</p>
  
  <pre><code>@Scheduled(cron = "#{systemEnvironment['db_cron']}")
  def void schedule() {
  
  }
  </code></pre>
  
  <p>Next set the environment variable as:</p>
  
  <pre><code>export db_cron="0 19 21 * * *"
  </code></pre>
  
  <p>However, I get the runtime error:</p>
  
  <pre><code>Cron expression must consist of 6 fields 
    (found 1 in "#{systemEnvironment['db_cron']}")
  </code></pre>
  
  <p>What can be going wrong?</p>
  
  <hr>
  
  <p><strong>EDIT</strong></p>
  
  <p>I have also tried: <code>@Scheduled(cron = "${db_cron}")</code></p>
  
  <p>But this returns a <strong>compile</strong> time error:</p>
  
  <pre><code>/Users/snowch/repos/sales/Prospects/Snow/Plugwise/etl_service/src/main/groovy/com/ibm/etl/Application.groovy: 52: Expected '$db_cron' to be an 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'; but found type 'java.lang.Object' in @org.springframework.scheduling.annotation.Scheduled
   @ line -1, column -1.
  2 errors
  
  :compileGroovy FAILED
  
  FAILURE: Build failed with an exception.
  </code></pre>
  
  <p>I have tried <code>@Scheduled(cron = "#{db_cron}")</code></p>
  
  <p>But the <strong>runtime</strong> error was:</p>
  
  <pre><code>Exception in thread "main" groovy.lang.MissingMethodException: No signature of method: static org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.setSystemPropertiesMode() is applicable for argument types: (java.lang.Integer) values: [2]
  Possible solutions: setSystemPropertiesMode(int), setSystemPropertiesModeName(java.lang.String)
      at groovy.lang.MetaClassImpl.invokeStaticMissingMethod(MetaClassImpl.java:1373)
      at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1359)
      at org.codehaus.groovy.runtime.callsite.StaticMetaClassSite.call(StaticMetaClassSite.java:50)
      at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
      at com.ibm.etl.Application.main(Application.groovy:43)
  </code></pre>
  
  <p>Note the environment variable is set as follows:</p>
  
  <pre><code>snowch$ echo "$db_cron"
  0 19 21 * * *
  </code></pre>