spring-projects/spring-shell
 Watch    55
 Star    809
 Fork    396

= Spring Shell image:https://github.com/spring-projects/spring-shell/actions/workflows/ci.yml/badge.svg["CI", link="https://github.com/spring-projects/spring-shell/actions/workflows/ci.yml"]

== Latest news

== About Spring Shell

Spring Shell helps you create Spring-powered, production-grade applications targeting the CLI space. It takes an opinionated view of the Spring platform so that new and existing users can quickly get the bits they need.

You can use Spring Shell to create stand-alone Java applications that can be started using java -jar or more sophisticated GraalVM native ways to create platform dependant apps.

Our primary goals are:

  • Provide a fast and accessible getting started experience for shell development.
  • Be opinionated, but get out of the way quickly as requirements start to diverge from the defaults.

== Installation and Getting Started

Go to https://start.spring.io[start.spring.io] and generate a new project with Spring Shell dependency. Here is a quick link to generate a Maven project with Spring Shell dependency: https://start.spring.io/#!type=maven-project&language=java&platformVersion=4.0.1&packaging=jar&configurationFileFormat=properties&jvmVersion=17&groupId=com.example&artifactId=demo&name=demo&description=Demo%20project%20for%20Spring%20Boot&packageName=com.example.demo&dependencies=spring-shell[Spring Initializr link].

Unzip the generated project and open it in your favorite IDE. Now edit the main application class DemoApplication and add the following command:

[source,java,indent=0]

import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.shell.core.command.annotation.Command;

@SpringBootApplication public class DemoApplication {

@Command
public String hi() {
	return "hi";
}

public static void main(String[] args) {
	SpringApplication.run(DemoApplication.class, args);
}

}

Build the application using Maven:

[source,bash]

$>./mvnw package -DskipTests

After building the application, you can run it in interactive mode as an executable jar:

[source,bash]

$>java -jar target/demo-0.0.1-SNAPSHOT.jar

shell:>help AVAILABLE COMMANDS

Built-In Commands history: Display or save the history of previously run commands clear: Clear the terminal screen help: Display help about available commands quit, exit: Exit the shell version: Show version info script: Execute commands from a script file SpringShellApplication Commands hi: N/A

shell:>hi hi

== Tutorials and Sample apps

You can find complete tutorials and sample applications in the spring-shell-samples repository:

== Getting Help Are you having trouble with Spring Shell? We want to help!

Join our https://github.com/spring-projects/spring-shell/discussions[GitHub Discussion] section and post your question there.

== Reporting Issues Spring Shell uses https://github.com/spring-projects/spring-shell/issues[GitHub Issues] to record bugs and feature requests. If you want to raise an issue, please follow the recommendations below:

  • Before you log a bug, please search the issue tracker to see if someone has already reported the problem.
  • If the issue doesn't already exist, create a new issue.
  • Please provide as much information as possible with the issue report. We need to know the Spring Boot and Shell version, operating system, and the JVM version you're using.
  • If you need to paste code or include a stack trace, please use Markdown's +++```+++ escapes before and after your text.
  • If possible, try to create a test case or project that replicates the problem and attach it to the issue.

== Building from Source Building and running tests:

[source,bash]

$>git clone git@github.com:spring-projects/spring-shell.git $>cd spring-shell $>./mvnw install

== Building the Documentation

The documentation is built using Antora and can be run using the Antora Maven plugin.

[source,bash]

$>./mvnw antora -pl spring-shell-docs

After running the command, you can view the site for this branch in spring-shell-docs/target/site.

== License Spring Shell is Open Source software released under the https://www.apache.org/licenses/LICENSE-2.0.html[Apache 2.0 license].

关于
Spring based shell
最后更新于  13 hours ago