diff --git a/README.md b/README.md index e13e7573e4b..72bc0e14e61 100644 --- a/README.md +++ b/README.md @@ -1,145 +1,173 @@ # Spring Boot -Spring Boot makes it easy to create Spring-powered, production-grade applications and -services with absolute minimum fuss. It takes an opinionated view of the Spring platform +Spring Boot makes it easy to create Spring-powered, production-grade applications and +services with absolute minimum fuss. It takes an opinionated view of the Spring platform so that new and existing users can quickly get to the bits they need. -You can use Spring Boot to create stand-alone Java applications that can be started using +You can use Spring Boot to create stand-alone Java applications that can be started using `java -jar` or more traditional WAR deployments. We also provide a command line tool that runs spring scripts. Our primary goals are: * Provide a radically faster and widely accessible getting started experience for all - Spring development +Spring development * Be opinionated out of the box, but get out of the way quickly as requirements start to - diverge from the defaults +diverge from the defaults * Provide a range of non-functional features that are common to large classes of projects - (e.g. embedded servers, security, metrics, health checks, externalized configuration) +(e.g. embedded servers, security, metrics, health checks, externalized configuration) * Absolutely no code generation and no requirement for XML configuration -## Installing the CLI +## Spring Boot CLI +The Spring Boot CLI is a command line tool that can be used if you want to quickly +prototype with Spring. It allows you to run [Groovy](http://groovy.codehaus.org/) scripts, +which means that you have a familiar Java-like syntax, without so much boilerplate code. -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 (there are even some issues with the `1.7.0_25` build of openjdk, -so stick to earlier builds or use `1.6` for preference). You should -check your current Java installation before you begin: +You don't need to use the CLI to work with Spring Boot but it's definitely the quickest +way to get a Spring application off the ground. + +### Installing the CLI +> **Note:** If you don't want to use the CLI, +> [jump ahead to the Java example](#quick-start-java-example). + +You need [Java SDK v1.6](http://www.java.com) or higher to run the command line tool +(there are even some issues with the `1.7.0_25` build of openjdk, so stick to earlier +builds or use `1.6` for preference). You should check your current Java installation +before you begin: $ java -version -### MacOS with Brew +### Manual installation +You can download the Spring CLI distribution from the Spring software repository: -If you are on a Mac and using [homebrew](http://brew.sh/), all you need do to install the Spring Boot CLI is: +* [spring-boot-cli-0.5.0.BUILD-SNAPSHOT-bin.zip](http://repo.springframework.org/milestone/org/springframework/boot/spring-boot-cli/0.5.0.M1/spring-boot-cli-0.5.0.M1-bin.zip) +* [spring-boot-cli-0.5.0.BUILD-SNAPSHOT-bin.tar.gz](http://repo.springframework.org/milestone/org/springframework/boot/spring-boot-cli/0.5.0.M1/spring-boot-cli-0.5.0.M1-bin.tar.gz) - $ brew install spring-boot-cli - -It will install `/usr/local/bin/spring`. Now you can jump right to a [quick start example](#quick-start-groovy-example). +Cutting edge [snapshot distributions](http://repo.springframework.org/snapshot/org/springframework/boot/spring-boot-cli/) +are also available. -> **Note:** If you don't see the formula, you're installation of brew might be out-of-date. Just execute `brew update` and try again +Once downloaded, follow the [INSTALL](spring-boot-cli/src/main/content/INSTALL.txt) +instructions from the unpacked archive. -### Cross Platform `java - jar` -An alternative way to install Spring Boot CLI is to downloaded it from our Maven repository, and then you can use a shell `alias`: +### OSX Homebrew installation +If you are on a Mac and using [homebrew](http://brew.sh/), all you need to do to install +the Spring Boot CLI is: - $ 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" + $ brew install spring-boot-cli -If you don't have `wget` installed on your system you might have -`curl` (with `-o` for setting the output filename). Windows users -will need [cygwin](http://www.cygwin.org) to use the `alias` command, -but they can run `java -jar` directly and that will work. +Homebrew will install `spring` to `/usr/local/bin`. Now you can jump right to a +[quick start example](#quick-start-script-example). -Complete installation including a downloadable `.zip` with a shell -script TBD. +> **Note:** If you don't see the formula, you're installation of brew might be +> out-of-date. Just execute `brew update` and try again. - -## Quick Start Script Example +### Quick start script example Here's a really simple web application. Create a file called `app.groovy`: ```groovy @Controller class ThisWillActuallyRun { - + @RequestMapping("/") @ResponseBody String home() { return "Hello World!" } - + } ``` Then run it from a shell: ``` -$ spring run app.groovy --verbose -$ curl localhost:8080 -Hello World! +$ spring run app.groovy ``` -It might take a few minutes the first time you do this while some -dependencies are downloaded (which is why we added the `--verbose` -option - you can remove that if you prefer). If you are a maven user -and have a fully loaded local cache with all the required dependencies -you will find it is much faster. +> **Note:** It will take some time when you first run the application as dependencies +> are downloaded, subsequent runs will be much quicker. - -## Quick Start Java Example +Open [http://localhost:8080](http://localhost:8080) in your favorite web browser and you +should see the following output: +> Hello World! + +## Spring Boot with Java If you don't want to use the command line tool, or you would rather work using Java and -an IDE you can. Create a `pom.xml` (or the equivalent with your favourite build system): +an IDE you can. Here is how you build the same example using Java. + +### Quick start Maven POM +You will need to install [Apache Maven](http://maven.apache.org/) v3.0.5 or above to build +this example. -`pom.xml` +Create a `pom.xml` to import the appropriate Spring Boot starters: ```xml - - 4.0.0 - myproject - 0.0.1-SNAPSHOT - - org.springframework.boot - spring-boot-starter-parent - 0.5.0.M1 - - - - org.springframework.boot - spring-boot-starter-web - - - - - - ${project.groupId} - spring-boot-maven-plugin - - - - - - - spring-milestone - http://repo.springsource.org/milestone - - - - - spring-milestone - http://repo.springsource.org/milestone - - + + 4.0.0 + + com.example + myproject + 0.0.1-SNAPSHOT + + + + org.springframework.boot + spring-boot-starter-parent + 0.5.0.M1 + + + + + + org.springframework.boot + spring-boot-starter-web + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + + + + spring-snapshots + http://repo.springsource.org/snapshot + true + + + spring-milestones + http://repo.springsource.org/milestone + true + + + + + spring-snapshots + http://repo.springsource.org/snapshot + + + spring-milestones + http://repo.springsource.org/milestone + + ``` -Then just add a class in `src/main/java` with a `main()` method that -calls `SpringApplication` and add `@EnableAutoConfiguration`, e.g: +> **Note:** If you prefer [Gradle](http://www.gradle.org) as your build system, we provide +> a [plugin](spring-boot-tools/spring-boot-gradle-plugin/README.md) that can help you +> package an executable JAR. -`src/main/java/SampleController.java` +### Quick start Java example +Here is the main class for a simple web application (just save the content to +`src/main/java/SampleController.java`): ```java import org.springframework.boot.*; @@ -151,7 +179,7 @@ import org.springframework.web.bind.annotation.*; @EnableAutoConfiguration public class SampleController { - @RequestMapping("/") + @RequestMapping("/") @ResponseBody String home() { return "Hello World!"; @@ -163,63 +191,73 @@ public class SampleController { } ``` +Other than import statements, the main difference between this +example and the earlier Groovy script is the `main()` method that calls +`SpringApplication` and the `@EnableAutoConfiguration` annotation. + You can run this application by building a `jar` and executing it: ``` $ mvn package $ java -jar target/myproject-0.0.1-SNAPSHOT.jar -... Spring starting up ... ``` -and in anonther terminal: +Open [http://localhost:8080](http://localhost:8080) in your favorite web browser and you +should see the following output: +> Hello World! -``` -$ curl localhost:8080 -Hello World! -``` +## Building Spring Boot from source +You don't need to build from source to use Spring Boot (it's in +[repo.springsource.org](http://repo.springsource.org)), 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.5 or above. -## Spring Boot Modules -There are a number of modules in Spring Boot. Here are the important ones: + $ mvn clean install + +_Also see [CONTRIBUTING.md](CONTRIBUTING.md) if you wish to submit pull requests._ + +## Further Reading +There are a number of modules in Spring Boot, if you want learn more about each one +please refer to the appropriate README.md file: + +> **Note:** We are currently still working on documentation for Spring Boot. ### spring-boot The main library providing features that support the other parts of Spring Boot, these include: * The `SpringApplication` class, providing static convenience methods that make it easy - to write a stand-alone Spring Application. Its sole job is to create and refresh an - appropriate Spring `ApplicationContext` +to write a stand-alone Spring Application. Its sole job is to create and refresh an +appropriate Spring `ApplicationContext` * Embedded web applications with a choice of container (Tomcat or Jetty for now) * First class externalized configuration support * Convenience `ApplicationContext` initializers, including support for sensible logging - defaults. +defaults _See [spring-boot/README.md](spring-boot/README.md)._ - ### spring-boot-autoconfigure -Spring Boot can configure large parts of common applications based on the content -of their classpath. A single `@EnableAutoConfiguration` annotation triggers +Spring Boot can configure large parts of common applications based on the content +of their classpath. A single `@EnableAutoConfiguration` annotation triggers auto-configuration of the Spring context. -Auto-configuration attempts to deduce which beans a user might need. For example, If -'HSQLDB' is on the classpath, and the user has not configured any database connections, -then they probably want an in-memory database to be defined. Auto-configuration will +Auto-configuration attempts to deduce which beans a user might need. For example, If +`HSQLDB` is on the classpath, and the user has not configured any database connections, +then they probably want an in-memory database to be defined. Auto-configuration will always back away as the user starts to define their own beans. _See [spring-boot-autoconfigure/README.md](spring-boot-autoconfigure/README.md)._ - ### spring-boot-starters Starters are a set of convenient dependency descriptors that you can include in your application. You get a one-stop-shop for all the Spring and related technology that you need without having to hunt through sample code and copy paste loads of dependency descriptors. For example, if you want to get started using Spring and JPA for -database access just include the `spring-boot-starter-data-jpa` dependency in your +database access just include the `spring-boot-starter-data-jpa` dependency in your project, and you are good to go. _See [spring-boot-starters/README.md](spring-boot-starters/README.md)._ - ### spring-boot-cli The Spring command line application compiles and runs Groovy source, making it super easy to write the absolute minimum of code to get an application running. Spring CLI @@ -227,73 +265,61 @@ can also watch files, automatically recompiling and restarting when they change. *See [spring-boot-cli/README.md](spring-boot-cli/README.md).* - ### spring-boot-actuator -Spring Boot Actuator provides additional auto-configuration to decorate your application -with features that make it instantly deployable and supportable in production. For -instance if you are writing a JSON web service then it will provide a server, security, -logging, externalized configuration, management endpoints, an audit abstraction, and +Spring Boot Actuator provides additional auto-configuration to decorate your application +with features that make it instantly deployable and supportable in production. For +instance if you are writing a JSON web service then it will provide a server, security, +logging, externalized configuration, management endpoints, an audit abstraction, and more. If you want to switch off the built in features, or extend or replace them, it makes that really easy as well. _See [spring-boot-actuator/README.md](spring-boot-actuator/README.md)._ - ### spring-boot-loader -Spring Boot Loader provides the secret sauce that allows you to build a single jar file -that can be launched using `java -jar`. Generally you will not need to use -`spring-boot-loader` directly but instead work with the -[Gradle](spring-boot-tools/spring-boot-gradle-plugin/README.md) or +Spring Boot Loader provides the secret sauce that allows you to build a single jar file +that can be launched using `java -jar`. Generally you will not need to use +`spring-boot-loader` directly, but instead work with the +[Gradle](spring-boot-tools/spring-boot-gradle-plugin/README.md) or [Maven](spring-boot-tools/spring-boot-maven-plugin/README.md) plugin. _See [spring-boot-loader/README.md](spring-boot-tools/spring-boot-loader/README.md)._ - ## Samples Groovy samples for use with the command line application are available in [spring-boot-cli/samples](spring-boot-cli/samples). To run the CLI samples type `spring run .groovy` from samples directory. Java samples are available in [spring-boot-samples](spring-boot-samples) and should -be build with maven and run use `java -jar target/.jar`. The following java +be build with maven and run use `java -jar target/.jar`. The following java samples are provided: * [spring-boot-sample-simple](spring-boot-samples/spring-boot-sample-simple) - - A simple command line application +A simple command line application * [spring-boot-sample-tomcat](spring-boot-samples/spring-boot-sample-tomcat) - - Embedded Tomcat +Embedded Tomcat * [spring-boot-sample-jetty](spring-boot-samples/spring-boot-sample-jetty) - - Embedded Jetty +Embedded Jetty * [spring-boot-sample-actuator](spring-boot-samples/spring-boot-sample-actuator) - - Simple REST service with production features +Simple REST service with production features * [spring-boot-sample-actuator-ui](spring-boot-samples/spring-boot-sample-actuator-ui) - - A web UI example with production features +A web UI example with production features * [spring-boot-sample-web-ui](spring-boot-samples/spring-boot-sample-web-ui) - - A thymeleaf web application +A thymeleaf web application * [spring-boot-sample-web-static](spring-boot-samples/spring-boot-sample-web-static) - - A web application service static files +A web application service static files * [spring-sample-batch](spring-boot-samples/spring-sample-batch) - - Define and run a Batch job in a few lines of code +Define and run a Batch job in a few lines of code * [spring-sample-data-jpa](spring-boot-samples/spring-sample-data-jpa) - - Spring Data JPA + Hibernate + HSQLDB +Spring Data JPA + Hibernate + HSQLDB * [spring-boot-sample-integration](spring-boot-samples/spring-boot-sample-integration) - - A spring integration application +A spring integration application * [spring-boot-sample-profile](spring-boot-samples/spring-boot-sample-profile) - - example showing Spring's `@profile` support +example showing Spring's `@profile` support * [spring-boot-sample-traditional](spring-boot-samples/spring-boot-sample-traditional) - - shows more traditional WAR packaging - (but also executable using `java -jar`) +shows more traditional WAR packaging +(but also executable using `java -jar`) * [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. +Example show how Spring Boot can be mixed with traditional XML configuration (we +generally recommend using Java `@Configuration` whenever possible) - $ mvn clean install - -_Also see [CONTRIBUTING.md](CONTRIBUTING.md) if you wish to submit pull requests._ diff --git a/spring-boot-actuator/README.md b/spring-boot-actuator/README.md index 8aa9a5b8db0..8ef9bab587d 100644 --- a/spring-boot-actuator/README.md +++ b/spring-boot-actuator/README.md @@ -1,5 +1,8 @@ # Spring Boot - Actuator +> **Note:** Some of this documentation covers concepts from other modules, it will be +> cleaned up before the final release. + The aim of this project is minimum fuss for getting applications up and running in production, and in other environments. There is a strong emphasis on implementing RESTful web services but many features diff --git a/spring-boot-autoconfigure/README.md b/spring-boot-autoconfigure/README.md index 055fe0d6eb5..bb9c8badd21 100644 --- a/spring-boot-autoconfigure/README.md +++ b/spring-boot-autoconfigure/README.md @@ -1 +1,4 @@ # Spring Boot - AutoConfigure + +> We are currently still working on documentation for Spring Boot. Please check back +> in the future. \ No newline at end of file diff --git a/spring-boot-cli/README.md b/spring-boot-cli/README.md index 95230835c3f..16fc65c908b 100644 --- a/spring-boot-cli/README.md +++ b/spring-boot-cli/README.md @@ -1 +1,4 @@ # Spring Boot - CLI + +> We are currently still working on documentation for Spring Boot. Please check back +> in the future. \ No newline at end of file diff --git a/spring-boot-samples/README.md b/spring-boot-samples/README.md index 58315bfe91f..d496294c03f 100644 --- a/spring-boot-samples/README.md +++ b/spring-boot-samples/README.md @@ -1,2 +1,4 @@ # Spring Boot - Samples +> We are currently still working on documentation for Spring Boot. Please check back +> in the future. \ No newline at end of file diff --git a/spring-boot-starters/README.md b/spring-boot-starters/README.md index fc57028c671..f6776e52435 100644 --- a/spring-boot-starters/README.md +++ b/spring-boot-starters/README.md @@ -1,4 +1,4 @@ # Spring Boot - Starters -Aggregated dependencies for starter projects with an opinionated -choice of Spring and related useful technologies. +> We are currently still working on documentation for Spring Boot. Please check back +> in the future. diff --git a/spring-boot-tools/spring-boot-gradle-plugin/README.md b/spring-boot-tools/spring-boot-gradle-plugin/README.md index b059aacb9f0..5e87a7bb210 100644 --- a/spring-boot-tools/spring-boot-gradle-plugin/README.md +++ b/spring-boot-tools/spring-boot-gradle-plugin/README.md @@ -1 +1,4 @@ # Spring Boot - Gradle Plugin + +> We are currently still working on documentation for Spring Boot. Please check back +> in the future. \ No newline at end of file diff --git a/spring-boot-tools/spring-boot-loader-tools/README.md b/spring-boot-tools/spring-boot-loader-tools/README.md index 707ed067e3f..8ab1a28e759 100644 --- a/spring-boot-tools/spring-boot-loader-tools/README.md +++ b/spring-boot-tools/spring-boot-loader-tools/README.md @@ -1,5 +1,4 @@ # Spring Launcher -A very thin Java main for executable JAR and WAR -archives. `JarLauncher` and `WarLauncher` know how to access classpath -resources and dependencies in nested jar files. +> We are currently still working on documentation for Spring Boot. Please check back +> in the future. \ No newline at end of file diff --git a/spring-boot-tools/spring-boot-loader/README.md b/spring-boot-tools/spring-boot-loader/README.md index 3bbeb9af3fc..6f3181cc838 100644 --- a/spring-boot-tools/spring-boot-loader/README.md +++ b/spring-boot-tools/spring-boot-loader/README.md @@ -1,5 +1,4 @@ # Spring Boot - Loader -A very thin Java main for executable JAR and WAR -archives. `JarLauncher` and `WarLauncher` know how to access classpath -resources and dependencies in nested jar files. +> We are currently still working on documentation for Spring Boot. Please check back +> in the future. diff --git a/spring-boot-tools/spring-boot-maven-plugin/README.md b/spring-boot-tools/spring-boot-maven-plugin/README.md index a55bd7a9cf8..be25710acff 100644 --- a/spring-boot-tools/spring-boot-maven-plugin/README.md +++ b/spring-boot-tools/spring-boot-maven-plugin/README.md @@ -1,5 +1,8 @@ # Spring Boot - Maven Plugin +> **Note:** We are currently still working on documentation for Spring Boot. This +> README is not yet complete, please check back in the future. + A maven plugin for building executable JAR and WAR files. To use it, configure your project to build a JAR or WAR (as appropriate) in the normal way, and then add the Spring plugin to your ``