Spring Shell with Spring Boot Driven
<dependency>
<groupId>org.mvnsearch.spring.boot</groupId>
<artifactId>spring-boot-starter-shell</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.4.0.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- do not enable it, this will creats a non standard jar and cause autoconfig to fail -->
<executable>false</executable>
</configuration>
</plugin>
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringShellApplication.run(DemoApplication.class, args);
}
}
@Component
public class HelloCommands implements CommandMarker {
@CliCommand(value = "hello", help = "CMS ")
public String hello() {
return "hello";
}
}
$ mvn -DskipTests clean package
$ java -jar target/xxxx.jar
spring.main.banner-mode=off
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!--stdout appender-->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="ERROR">
<appender-ref ref="CONSOLE"/>
</root>
</configuration>