Skip to content

Commit 5117e73

Browse files
committed
Add hello world sample
Issue #1158
1 parent 1711379 commit 5117e73

File tree

4 files changed

+60
-0
lines changed

4 files changed

+60
-0
lines changed

spring-shell-samples/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<description>Samples applications of how to use Spring Shell</description>
1515

1616
<modules>
17+
<module>spring-shell-sample-hello-world</module>
1718
<module>spring-shell-sample-catalog</module>
1819
<module>spring-shell-sample-commands</module>
1920
<module>spring-shell-sample-e2e</module>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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</artifactId>
12+
<name>Spring Shell Samples - Hello World</name>
13+
<packaging>jar</packaging>
14+
<description>Hello World Spring 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 numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package org.springframework.shell.samples.helloworld;
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.EnableCommand;
7+
import org.springframework.shell.core.command.annotation.Option;
8+
9+
@SpringBootApplication
10+
@EnableCommand(SpringShellApplication.class)
11+
@Command
12+
public class SpringShellApplication {
13+
14+
public static void main(String[] args) {
15+
SpringApplication.run(SpringShellApplication.class, args);
16+
}
17+
18+
@Command
19+
public String hello(@Option(defaultValue = "World") String name) {
20+
return "Hello " + name + "!";
21+
}
22+
23+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
spring.shell.interactive.enabled=true

0 commit comments

Comments
 (0)