How to disable command line properties in spring boot How to disable command line properties in spring boot

Spring Boot Application converts any command line arguments starting with --, such as --spring.profiles.active=dev to a property by default and adds them to the Spring Environment. Command line properties always take precedence over other property sources.

If you do not want command line properties to be added to the Environment, you can disable them from SpringBootApplication main method as follows:-

@SpringBootApplication
public class SpringBootDemoApplication {

    public static void main(String[] args) {

        SpringApplication app = new SpringApplication(SpringBootDemoApplication.class);
        app.setAddCommandLineProperties(false);
        app.run(args);
    }
}