File tree Expand file tree Collapse file tree 7 files changed +79
-8
lines changed
spring-shell-sample-hello-world-spring-boot
java/org/springframework/shell/samples/helloworld/boot
spring-shell-sample-hello-world
java/org/springframework/shell/samples/helloworld Expand file tree Collapse file tree 7 files changed +79
-8
lines changed Original file line number Diff line number Diff line change 1515
1616 <modules >
1717 <module >spring-shell-sample-hello-world</module >
18+ <module >spring-shell-sample-hello-world-spring-boot</module >
1819 <module >spring-shell-sample-catalog</module >
1920 <module >spring-shell-sample-commands</module >
2021 </modules >
Original file line number Diff line number Diff line change 1+ <project xmlns =" http://maven.apache.org/POM/4.0.0" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
2+ xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" >
3+ <modelVersion >4.0.0</modelVersion >
4+
5+ <parent >
6+ <groupId >org.springframework.shell</groupId >
7+ <artifactId >spring-shell-samples</artifactId >
8+ <version >4.0.0-SNAPSHOT</version >
9+ </parent >
10+
11+ <artifactId >spring-shell-sample-hello-world-spring-boot</artifactId >
12+ <name >Spring Shell Samples - Hello World with Spring Boot</name >
13+ <packaging >jar</packaging >
14+ <description >Hello World Spring Boot based Shell application</description >
15+
16+ <dependencies >
17+ <dependency >
18+ <groupId >org.springframework.shell</groupId >
19+ <artifactId >spring-shell-starter</artifactId >
20+ <version >${project.parent.version} </version >
21+ </dependency >
22+
23+ <dependency >
24+ <groupId >org.hibernate.validator</groupId >
25+ <artifactId >hibernate-validator</artifactId >
26+ <version >${hibernate-validator.version} </version >
27+ </dependency >
28+ <dependency >
29+ <groupId >org.glassfish</groupId >
30+ <artifactId >jakarta.el</artifactId >
31+ <version >${jakarta.el.version} </version >
32+ </dependency >
33+ </dependencies >
34+
35+ </project >
Original file line number Diff line number Diff line change 1+ package org .springframework .shell .samples .helloworld .boot ;
2+
3+ import org .springframework .boot .SpringApplication ;
4+ import org .springframework .boot .autoconfigure .SpringBootApplication ;
5+ import org .springframework .shell .core .command .annotation .Command ;
6+ import org .springframework .shell .core .command .annotation .Option ;
7+
8+ @ SpringBootApplication
9+ public class SpringShellApplication {
10+
11+ public static void main (String [] args ) {
12+ SpringApplication .run (SpringShellApplication .class , args );
13+ }
14+
15+ @ Command
16+ public String hello (@ Option (defaultValue = "World" ) String name ) {
17+ return "Hello " + name + "!" ;
18+ }
19+
20+ }
Original file line number Diff line number Diff line change 1+ <configuration >
2+
3+ <appender name =" CONSOLE" class =" ch.qos.logback.core.ConsoleAppender" >
4+ <layout class =" ch.qos.logback.classic.PatternLayout" >
5+ <Pattern >
6+ %d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n
7+ </Pattern >
8+ </layout >
9+ </appender >
10+
11+ <root level =" info" >
12+ <appender-ref ref =" CONSOLE" />
13+ </root >
14+
15+ </configuration >
Original file line number Diff line number Diff line change 1616 <dependencies >
1717 <dependency >
1818 <groupId >org.springframework.shell</groupId >
19- <artifactId >spring-shell-starter </artifactId >
19+ <artifactId >spring-shell-core </artifactId >
2020 <version >${project.parent.version} </version >
2121 </dependency >
2222
Original file line number Diff line number Diff line change 11package org .springframework .shell .samples .helloworld ;
22
3- import org .springframework .boot .SpringApplication ;
4- import org .springframework .boot .autoconfigure .SpringBootApplication ;
3+ import org .springframework .context .ApplicationContext ;
4+ import org .springframework .context .annotation .AnnotationConfigApplicationContext ;
5+ import org .springframework .shell .core .ShellRunner ;
56import org .springframework .shell .core .command .annotation .Command ;
67import org .springframework .shell .core .command .annotation .EnableCommand ;
78import org .springframework .shell .core .command .annotation .Option ;
89
9- @ SpringBootApplication
1010@ EnableCommand (SpringShellApplication .class )
11- @ Command
1211public class SpringShellApplication {
1312
14- public static void main (String [] args ) {
15- SpringApplication .run (SpringShellApplication .class , args );
13+ public static void main (String [] args ) throws Exception {
14+ ApplicationContext context = new AnnotationConfigApplicationContext (SpringShellApplication .class );
15+ ShellRunner runner = context .getBean (ShellRunner .class );
16+ runner .run (args );
1617 }
1718
1819 @ Command
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments