Spring Boot: Disabling Command Line Parameters

Subscribe to my newsletter and never miss my upcoming articles

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);
 
Share this