1

We have a web application that we would like to run in 'batch' mode, in this mode we dont want any endpoints exposed (for security reasons).

Is this possible in SpringBoot ?

Chris Milburn
  • 862
  • 1
  • 12
  • 20
  • Possible duplicate of [Can a spring boot @RestController be enabled/disabled using properties?](https://stackoverflow.com/questions/29958231/can-a-spring-boot-restcontroller-be-enabled-disabled-using-properties) – Justinas Jakavonis Apr 04 '18 at 08:22

1 Answers1

1

I'd recommend you use profiles on @Controller or @RestController classes:

@Profile("!batch")
@RestController
public class SomeController { 
...
}

This means, SomeController will be created for the application, if the profile is anything but batch.

Then, you can run without batch profile and have the endpoints; or activate the profile via property, environment or from command line with the batch profile:

java -jar some-app.jar --spring.profiles.active=batch

See Spring API docs for details on how to define and activate profiles

MuratOzkan
  • 2,599
  • 13
  • 25