Skip to main content

Command Palette

Search for a command to run...

Spring Boot: Disabling Command Line Parameters

Published
1 min read

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);
2 views

More from this blog

C

Coding Saint - Simple Short Tutorials

52 posts

I am Kumar Pallav, a passionate programmer.I love java, open source & microservices . I create Simple , Short Tutorials Follow me at https://twitter.com/kumar_pallav