Can a spring boot @RestController be enabled/disabled using properties?
I found a simple solution using @ConditionalOnExpression: @RestController @ConditionalOnExpression(“${my.controller.enabled:false}”) @RequestMapping(value = “foo”, produces = “application/json;charset=UTF-8”) public class MyController { @RequestMapping(value = “bar”) public ResponseEntity<String> bar( return new ResponseEntity<>(“Hello world”, HttpStatus.OK); } } With this annotation added, unless I have my.controller.enabled=true in my application.properties file, the controller won’t start at all. You can also use the … Read more