2017-11-30 9 views
0

스프링 셸을 사용하고 있는데 문제가 없습니다. 하지만 난 명령에 예를 들어 명령에 내장 된 명령을 실행하고 싶습니다.
어떻게 할 수 있습니까? 당신이 심판 할 수스프링 셸에서 exit 내장 명령을 실행하는 방법은 무엇입니까?

@Component 
public class runCommand implements CommandMarker { 

    @CliCommand(value = "exit", help = "") 
    public void exit() { 
     // run exit built in command to exit 
    } 
} 

답변

0

, disabling_specific_commands

public static void main(String[] args) throws Exception { 
     String[] disabledCommands = {"--spring.shell.command.exit.enabled=true"}; 
     String[] fullArgs = StringUtils.concatenateStringArrays(args, disabledCommands); 
     SpringApplication.run(MyApp.class, fullArgs); 
} 
+0

감사합니다. java -jar ... 명령 프롬프트에서 내 응용 프로그램을 실행하고 main 메서드가 아닙니다. 나는 어떻게해야합니까? –

+0

위 코드는 main 또는 init 함수에 코드를 추가해야 함을 의미합니다. –

+0

이것은 일부 명령을 비활성화하는 방법입니다. 클래스에 정의 된 다른 메서드를 실행하여 기본 제공 명령을 호출하고 싶습니다. –