Spring Boot: Disabling Command Line Parameters

Kumar Pallav
Kumar Pallav
I am a passionate java programmer, Open Source and Microservices lover, blogger and online instructor. I create Simple Short Tutorials

Spring Boot: Disabling Command Line Parameters

• Kumar Pallav

Property via command line

In previous example we have seen how to send command line parameter as –server.port , We can pass any parameter via command line. The parameters which are sent via command line can be accessed using @Value annotation ,using Environment variable provided by Spring as discussed above. Interestingly you might want to disable your application taking command line arguments. There could be compelling reasons to do so, one of them could be security . If so, go ahead adding following line in Main class and no more command line parameters will be considered.

SpringApplication.setAddCommandLineProperties(false);