Sunday, 14 February 2021

Spring Shell: Disable specific commands

By setting the property ‘spring.shell.command.<command>.enabled’ to false in the app Environment we can disable specific commands.

 

For example, below snippet disable the command clear and add.

@SpringBootApplication
public class App {

	public static void main(String args[]) {
		String[] disabledCommands = {"--spring.shell.command.clear.enabled=false", "--spring.shell.command.add.enabled=false"};
		args = StringUtils.concatenateStringArrays(args, disabledCommands);
		
		SpringApplication.run(App.class, args);
	}

}

 

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment