title: How to disable @Scheduled method via properties file?
body: <p>I have a Spring scheduled method that is periodically run:</p>
  <pre class="lang-java prettyprint-override"><code>@Scheduled(cron = &quot;${spring.cron.expression}&quot;)
  public void demonJob() { ... }
  </code></pre>
  <p>The cron expression is successfully read from the <code>application.properties</code>:</p>
  <pre class="lang-none prettyprint-override"><code>spring.cron.expression=0 0 * * * *
  </code></pre>
  <p>Now, I want to deploy my application to a special environment on which this particular scheduled method is not supposed to run. If I leave the cron property empty like this...</p>
  <pre class="lang-none prettyprint-override"><code>spring.cron.expression=
  </code></pre>
  <p>... I get the following exception:</p>
  <pre class="lang-none prettyprint-override"><code>Encountered invalid @Scheduled method 'demonJob': Cron expression must consist of 6 fields (found 0 in &quot;&quot;)
  </code></pre>
  <p>How can I disable the Scheduled method elegantly, ideally only by providing a different setting in <code>application.properties</code>?</p>