HomeAboutMeBlogGuest
© 2025 Sejin Cha. All rights reserved.
Built with Next.js, deployed on Vercel
🌚
[New] 우기팀
/
득윤
득윤
/
Spring Shell Hello World!
Spring Shell Hello World!
Spring Shell Hello World!

Spring Shell Hello World!

Spring Shell
Spring Shell's features include A simple, annotation driven, programming model to contribute custom commands Use of Spring Boot auto-configuration functionality as the basis for a command plugin strategy Tab completion, colorization, and script execution Customization of command prompt, shell history file name, handling of results and errors Dynamic enablement of commands based on domain specific criteria Integration with the bean validation API Already built-in commands, such as clear screen, gorgeous help, exit ASCII art Tables, with formatting, alignment, fancy borders, etc.
Spring Shell
https://spring.io/projects/spring-shell

Features

  • simple, annotation driven model로 custom command 작성
  • command 플러그인 전략(?)에 Spring Boot 자동 설정 사용
  • tab 자동완성, 터미널 색칠, script의 실행
  • command prompt, shell history, 실행 결과와 에러의 관리 및 커스터마이징
  • bean validation API와의 통합
  • clear, help, exit등 build-in commands 제공
  • ascii art, formatting 정렬, fancy borders 등등등

 
<dependency> <groupId>org.springframework.shell</groupId> <artifactId>spring-shell-starter</artifactId> <version>2.0.1.RELEASE</version> </dependency>
 

┌──->──┐ | org.springframework.shell.result.ResultHandlerConfig └──<-──┘
순환 참조
임시 해결
spring.main.allow-circular-references= true
application.properties

Command Examples

@ShellComponent public class MyCommands { @ShellMethod("Add two integers together.") public int add(int a, int b) { return a + b; } }
shell:>add 1 2 3
 
@ShellComponent public class TranslationCommands { private final TranslationService service; @Autowired public TranslationCommands(TranslationService service) { this.service = service; } @ShellMethod("Translate text from one language to another.") public String translate( @ShellOption String text, @ShellOption (defaultValue = "en_US") Locale from, @ShellOption Locale to ) { return service.translate(text, from, to); } } @Service public class TranslationService { public String translate(String text, Locale from, Locale to) { if (text.equals("Hello World!") && from.getLanguage().equals("en") && to.getLanguage().equals("ko")) { return "안녕 세상!"; } return "implementing..."; } }
shell:>translate "Hello World!" 안녕 세상! shell:>translate "Hello" --to fr_FR implementing...