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: 
Best way to use **ConditionalOnProperty** annotation for property based conditions. 

Here is example : 

```
@RestController
@ConditionalOnProperty(prefix="my.rest.controller", name="enabled", havingValue = "true")
public class MyRestController { ... }

```
I think that expression like 
`@ConditionalOnExpression("${my.rest.controller.enabled:false}")`

is very missleading. The ':false' part is telling that if there is no my.rest.controller.enabled property, whole expression should be evaluated to 'false'