title: @ConditionalOnProperty annotation not working in spring boot project
body: <p>I want to conditionally create a spring bean. I figured  <code>@ConditionalOnProperty</code> would serve that purpose.  I used it in my service class but I do not see the bean being created. </p>
  
  <p>Here is my bean that I want to be conditionally created</p>
  
  <pre><code>@Service
  @ConditionalOnProperty(value = "polling.enabled", havingValue = "true")
  public class MessageQueueService {
  
  @Scheduled(fixedDelay = INTERVAL_MS)
      public void execute() {
       //sysout
      }
  }
  </code></pre>
  
  <p>couple of thing to note.</p>
  
  <p>--  our service loads properties directly from consul(due to legacy reasons) and not through spring environment</p>
  
  <p>-- I hacked RestTemplate bean (below) to add custom propertyResource into environment. I did not know how to do it without creating another PropertySource bean instance.</p>
  
  <pre><code>@Configuration
  public class AppConfig {
  
  @Autowired
  ConfigurableEnvironment env;
  
  @Bean(name = "consulProps")
   public Properties properties() {
       Properties consulProperties = new ConsulDriver(env.getConsulUrl()).loadProperties();
      return properties;
   }
  
  @Bean
  @Autowired
  public RestTemplate restTemplate(@Qualifier(consulProps) Properties props) {
      MutablePropertySources sources = env.getPropertySources();
      sources.addFirst(pollingEnabled(props));
      return new RestTemplate();
      }
  
  private MapPropertySource pollingEnabled(Properties props) {
       String enabled = props.getProperty("polling.enabled"); // line 25
       Map&lt;String, Object&gt; map = new HashMap&lt;&gt;();
       if (StringUtils.isNotBlank(enabled)) {
             map.put("polling.enabled", enabled);
       }
       else {
            map.put("polling.enabled", "false");
       }
         return new MapPropertySource("polling", map);
      }
  
      @Bean
      public static PropertySourcesPlaceholderConfigurer propertyConfigIn() {
          return new PropertySourcesPlaceholderConfigurer();
      }
  }
  </code></pre>
  
  <p>when I run the service, it starts up. I have set up <code>polling.enabled</code> is <code>true</code> in consul. while debugging, I confirmed the value is set correctly in line 25. However, the bean is NOT created.
  if I comment-out the <code>@ConditionalOnProperty</code> from the class, bean is created and the scheduled Method is called.</p>
  
  <p>Any help to fix this is highly appreciated!!
  Thanks in advance</p>