From 9e7c9121d5341d8ca6a650a72a0fd5724e026375 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Mon, 5 Aug 2013 21:56:00 +0100 Subject: [PATCH] Fix ordering of README --- README.md | 120 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 95 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 98d26ecbc9..57c091f30e 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,29 @@ Our primary goals are: (e.g. embedded servers, security, metrics, health checks, externalized configuration) * Absolutely no code generation and no requirement for XML configuration +## Installing the CLI + +The Spring Boot command line tool uses +[Groovy](http://groovy.codehaus.org/) underneath so that we can +present simple Spring snippets that can 'just run'. You don't need +the CLI to get started (see the +[Java example](#quick-start-java-example) below), but it's the +quickest way to get a Spring application off the ground. You need +[Java SDK v1.6](http://www.java.com) or higher to run the command line +tool. You should check your current Java installation before you +begin: + + $ java -version + +Spring Boot CLI can be downloaded from our Maven repository, and then you can use a shell `alias`: + + $ wget http://maven.springframework.org/milestone/org/springframework/boot/spring-boot-cli/0.5.0.M1/spring-boot-cli-0.5.0.M1.jar + $ alias spring="java -jar `pwd`/spring-boot-cli-0.5.0.M1.jar" + +Complete installation including a downloadable `.zip` with a shell script TBD. + ## Quick Start Script Example -The Spring Boot command line tool uses [Groovy](http://groovy.codehaus.org/) underneath -so that we can present simple Spring snippets that can 'just run', for example: +Here's a really simple web application. Create a file called `app.groovy`: ```groovy @Controller @@ -34,18 +54,65 @@ class ThisWillActuallyRun { } ``` +Then run it from a shell: + ``` $ spring run app.groovy $ curl localhost:8080 Hello World! ``` -_See [below](#installing-the-cli) for command line tool installation instructions._ - + ## Quick Start Java Example If you don't want to use the command line tool, or you would rather work using Java and -an IDE you can. Just add a `main()` method that calls `SpringApplication` and -add `@EnableAutoConfiguration`: +an IDE you can. Create a `pom.xml` (or the equivalent with your favourite build system): + +`pom.xml` + +```xml + + myproject + 0.0.1-SNAPSHOT + + org.springframework.boot + spring-boot-starter-parent + 0.5.0.M1 + + + + org.springframework.boot + spring-boot-starter-web + ${spring.boot.version} + + + + + + ${project.groupId} + spring-boot-maven-plugin + + + + + + + spring-snapshots + http://repo.springsource.org/snapshot + true + + + + + spring-snapshots + http://repo.springsource.org/snapshot + true + + + +``` + +Then just add a class in `src/main/java` with a `main()` method that +calls `SpringApplication` and add `@EnableAutoConfiguration`, e.g: ```java import org.springframework.boot.*; @@ -70,28 +137,20 @@ public class SampleController { } ``` -_NOTE: the above example assumes your build system has imported the `spring-starter-web` maven pom._ +You can run this application by building a `jar` and executing it: -## Installing the CLI -You need [Java SDK v1.6](http://www.java.com) or higher to run the command line tool. You -should check your current Java installation before you begin: +``` +$ mvn package +$ java -jar target/myproject-0.0.1-SNAPSHOT.jar +... Spring starting up ... +``` - $ java -version - -Spring Boot CLI can be downloaded from our Maven repository, and then you can use a shell `alias` for the Spring Boot command line tool: +and in anonther terminal: - $ wget http://maven.springframework.org/milestone/org/springframework/boot/spring-boot-cli/0.5.0.M1/spring-boot-cli-0.5.0.M1.jar - $ alias spring="java -jar `pwd`/spring-boot-cli-0.5.0.M1.jar" - -Complete installation including a downloadable `.zip` with a shell script TBD. - -## Building from source -Spring Boot can be [built with maven](http://maven.apache.org/run-maven/index.html) v3.0 -or above. - - $ mvn clean install - -_Also see [CONTRIBUTING.md](CONTRIBUTING.md) if you wish to submit pull requests._ +``` +$ curl localhost:8080 +Hello World! +``` ## Spring Boot Modules There are a number of modules in Spring Boot. Here are the important ones: @@ -201,3 +260,14 @@ samples are provided: * [spring-boot-sample-xml](spring-boot-samples/spring-boot-sample-xml) - Example show how Spring Boot can be mixed with traditional XML configuration (we generally recommend using Java `@Configuration` whenever possible) + +## Building Spring Boot from source You don't need to build from +source to use Spring Boot (it's in the Maven repositories), but if you +want to try out the latest and greatest, Spring Boot can be +[built with maven](http://maven.apache.org/run-maven/index.html) v3.0 +or above. + + $ mvn clean install + +_Also see [CONTRIBUTING.md](CONTRIBUTING.md) if you wish to submit pull requests._ +