Question: I want to enable/disable a `@RestController` based on configuration, in order achieve it i'm trying to use the `@ConditionalOnExpression` annotation.

Using a static hardcoded value is working just fine:

```
@RestController
@ConditionalOnExpression("true")
public class MyRestController {

    @RequestMapping("/hi")
    public String hi() {
        return "hi";
    }
}

```

Yet, using a dynamic property value within a SpEL expression always results in **not** loading the `@RestController`:

```
@RestController
@ConditionalOnExpression("${my.rest.controller.enabled:false}")
public class MyRestController { ... }

```

Would really appreciate any ideas/best practices to resolve this.

Answer: 
To verify that a property in Spring Cloud Config is not provided, I used the following expression:

```
  /**
   * @return The Jms Template for sending the messages to the queue.
   */
  @Bean(name = "jmsTemplate")
  @ConditionalOnExpression("!'${jsk.messaging.jms.queue}'.isEmpty()")
  public JmsTemplate jmsTemplateForQueues() {
    JmsTemplate jmsTemplate = new JmsTemplate();
    CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory(activeMQConnectionFactory());
    jmsTemplate.setConnectionFactory(cachingConnectionFactory);
    return jmsTemplate;
  }

```
The spring expression language requires an expression to be evaluated. I've found that using :false to specify the ConditionalOnExpression doesn't evaluate properly for some reason, so I can suggest a couple of ways to work around this problem.

```
@ConditionalOnExpression("${my.rest.controller.enabled}==false")
// or
@ConditionalExpression("!${my.rest.controller.enabled}")

```