|
| 1 | += Spring Boot image:https://travis-ci.org/spring-projects/spring-boot.png?branch=master["Build Status", link="https://travis-ci.org/spring-projects/spring-boot"] |
| 2 | +:docs: http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference |
| 3 | + |
| 4 | +Spring Boot makes it easy to create Spring-powered, production-grade applications and |
| 5 | +services with absolute minimum fuss. It takes an opinionated view of the Spring platform |
| 6 | +so that new and existing users can quickly get to the bits they need. |
| 7 | + |
| 8 | +You can use Spring Boot to create stand-alone Java applications that can be started using |
| 9 | +`java -jar` or more traditional WAR deployments. We also provide a command line tool |
| 10 | +that runs spring scripts. |
| 11 | + |
| 12 | +Our primary goals are: |
| 13 | + |
| 14 | +* Provide a radically faster and widely accessible getting started experience for all |
| 15 | +Spring development |
| 16 | +* Be opinionated out of the box, but get out of the way quickly as requirements start to |
| 17 | +diverge from the defaults |
| 18 | +* Provide a range of non-functional features that are common to large classes of projects |
| 19 | +(e.g. embedded servers, security, metrics, health checks, externalized configuration) |
| 20 | +* Absolutely no code generation and no requirement for XML configuration |
| 21 | +
|
| 22 | +
|
| 23 | +
|
| 24 | +== Installation and Getting Started |
| 25 | +The {docs}/htmlsingle/[reference documentation] includes detailed |
| 26 | +{docs}/htmlsingle/#getting-started-installing-spring-boot[installation instructions] |
| 27 | +as well as a comprehensive {docs}/htmlsingle/#getting-started-first-application[``getting |
| 28 | +started''] guide. Documentation is published in {docs}/htmlsingle/[HTML], |
| 29 | +{docs}/pdf/spring-boot-reference.pdf[PDF] and {docs}/epub/spring-boot-reference.epub[EPUB] |
| 30 | +formats. |
| 31 | + |
| 32 | +Here is a quick teaser of a Spring Boot application: |
| 33 | + |
| 34 | +[source,java,indent=0] |
| 35 | +---- |
| 36 | + import org.springframework.boot.*; |
| 37 | + import org.springframework.boot.autoconfigure.*; |
| 38 | + import org.springframework.stereotype.*; |
| 39 | + import org.springframework.web.bind.annotation.*; |
| 40 | +
|
| 41 | + @Controller |
| 42 | + @EnableAutoConfiguration |
| 43 | + public class Example { |
| 44 | +
|
| 45 | + @RequestMapping("/") |
| 46 | + @ResponseBody |
| 47 | + String home() { |
| 48 | + return "Hello World!"; |
| 49 | + } |
| 50 | +
|
| 51 | + public static void main(String[] args) throws Exception { |
| 52 | + SpringApplication.run(Example.class, args); |
| 53 | + } |
| 54 | +
|
| 55 | + } |
| 56 | +---- |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | +== Getting help |
| 61 | +Having trouble with Spring Boot, We'd like to help! |
| 62 | + |
| 63 | +* Check the {docs}/htmlsingle/[reference documentation], especially the |
| 64 | + {docs}/htmlsingle/#howto[How-to's] -- they provide solutions to the most common |
| 65 | + questions. |
| 66 | +* Learn the Spring basics -- Spring Boot is builds on many other Spring projects, check |
| 67 | + the http://spring.io[spring.io] web-site for a wealth of reference documentation. If |
| 68 | + you are just starting out with Spring, try one of the http://spring.io/guides[guides]. |
| 69 | +* Ask a questions - we monitor http://stackoverflow.com[stackoverflow.com] for questions |
| 70 | + tagged with http://stackoverflow.com/tags/spring-boot[`spring-boot`]. |
| 71 | +* Report bugs with Spring Boot at https://github.com/spring-projects/spring-boot/issues. |
| 72 | + |
| 73 | + |
| 74 | + |
| 75 | +== Building from Source |
| 76 | +You don't need to build from source to use Spring Boot (binaries in |
| 77 | +http://repo.spring.io[repo.spring.io], but if you want to try out the latest and greatest, |
| 78 | +Spring Boot can be http://maven.apache.org/run-maven/index.html[built with maven] |
| 79 | +v3.0.5 or above. |
| 80 | + |
| 81 | +[indent=0] |
| 82 | +---- |
| 83 | + $ mvn clean install |
| 84 | +---- |
| 85 | + |
| 86 | +NOTE: You may need to increase the amount of memory available to Maven by setting |
| 87 | +a `MAVEN_OPTS` environment variable with the value `-Xmx512m -XX:MaxPermSize=128m` |
| 88 | + |
| 89 | +_Also see link:CONTRIBUTING.adoc[CONTRIBUTING.adoc] if you wish to submit pull requests, |
| 90 | +and in particular please fill out the |
| 91 | +https://support.springsource.com/spring_committer_signup[Contributor's Agreement] |
| 92 | +before your first change however trivial. (Or if you filed such an agreement already for |
| 93 | +another project just mention that in your pull request.)_ |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | +== Modules |
| 98 | +There are a number of modules in Spring Boot, here is a quick overview: |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | +=== spring-boot |
| 103 | +The main library providing features that support the other parts of Spring Boot, |
| 104 | +these include: |
| 105 | + |
| 106 | +* The `SpringApplication` class, providing static convenience methods that make it easy |
| 107 | +to write a stand-alone Spring Application. Its sole job is to create and refresh an |
| 108 | +appropriate Spring `ApplicationContext` |
| 109 | +* Embedded web applications with a choice of container (Tomcat or Jetty for now) |
| 110 | +* First class externalized configuration support |
| 111 | +* Convenience `ApplicationContext` initializers, including support for sensible logging |
| 112 | +defaults |
| 113 | + |
| 114 | + |
| 115 | + |
| 116 | +=== spring-boot-autoconfigure |
| 117 | +Spring Boot can configure large parts of common applications based on the content |
| 118 | +of their classpath. A single `@EnableAutoConfiguration` annotation triggers |
| 119 | +auto-configuration of the Spring context. |
| 120 | + |
| 121 | +Auto-configuration attempts to deduce which beans a user might need. For example, If |
| 122 | +`HSQLDB` is on the classpath, and the user has not configured any database connections, |
| 123 | +then they probably want an in-memory database to be defined. Auto-configuration will |
| 124 | +always back away as the user starts to define their own beans. |
| 125 | + |
| 126 | + |
| 127 | + |
| 128 | +=== spring-boot-starters |
| 129 | +Starters are a set of convenient dependency descriptors that you can include in |
| 130 | +your application. You get a one-stop-shop for all the Spring and related technology |
| 131 | +that you need without having to hunt through sample code and copy paste loads of |
| 132 | +dependency descriptors. For example, if you want to get started using Spring and JPA for |
| 133 | +database access just include the `spring-boot-starter-data-jpa` dependency in your |
| 134 | +project, and you are good to go. |
| 135 | + |
| 136 | + |
| 137 | + |
| 138 | +=== spring-boot-cli |
| 139 | +The Spring command line application compiles and runs Groovy source, making it super |
| 140 | +easy to write the absolute minimum of code to get an application running. Spring CLI |
| 141 | +can also watch files, automatically recompiling and restarting when they change. |
| 142 | + |
| 143 | + |
| 144 | + |
| 145 | +=== spring-boot-actuator |
| 146 | +Spring Boot Actuator provides additional auto-configuration to decorate your application |
| 147 | +with features that make it instantly deployable and supportable in production. For |
| 148 | +instance if you are writing a JSON web service then it will provide a server, security, |
| 149 | +logging, externalized configuration, management endpoints, an audit abstraction, and |
| 150 | +more. If you want to switch off the built in features, or extend or replace them, it |
| 151 | +makes that really easy as well. |
| 152 | + |
| 153 | + |
| 154 | + |
| 155 | +=== spring-boot-loader |
| 156 | +Spring Boot Loader provides the secret sauce that allows you to build a single jar file |
| 157 | +that can be launched using `java -jar`. Generally you will not need to use |
| 158 | +`spring-boot-loader` directly, but instead work with the |
| 159 | +link:spring-boot-tools/spring-boot-gradle-plugin[Gradle] or |
| 160 | +link:spring-boot-tools/spring-boot-maven-plugin[Maven] plugin. |
| 161 | + |
| 162 | + |
| 163 | + |
| 164 | +== Samples |
| 165 | +Groovy samples for use with the command line application are available in |
| 166 | +link:spring-boot-cli/samples[spring-boot-cli/samples]. To run the CLI samples type |
| 167 | +`spring run <sample>.groovy` from samples directory. |
| 168 | + |
| 169 | +Java samples are available in link:spring-boot-samples[spring-boot-samples] and should |
| 170 | +be built with maven and run by invoking `java -jar target/<sample>.jar`. The following |
| 171 | +java samples are provided: |
| 172 | + |
| 173 | +* link:spring-boot-samples/spring-boot-sample-simple[spring-boot-sample-simple] |
| 174 | + -- A simple command line application |
| 175 | +* link:spring-boot-samples/spring-boot-sample-tomcat[spring-boot-sample-tomcat] |
| 176 | + -- Embedded Tomcat |
| 177 | +* link:spring-boot-samples/spring-boot-sample-jetty[spring-boot-sample-jetty] |
| 178 | + -- Embedded Jetty |
| 179 | +* link:spring-boot-samples/spring-boot-sample-actuator[spring-boot-sample-actuator] |
| 180 | + -- Simple REST service with production features |
| 181 | +* link:spring-boot-samples/spring-boot-sample-actuator-ui[spring-boot-sample-actuator-ui] |
| 182 | + -- A web UI example with production features |
| 183 | +* link:spring-boot-samples/spring-boot-sample-web-ui[spring-boot-sample-web-ui] |
| 184 | + -- A thymeleaf web application |
| 185 | +* link:spring-boot-samples/spring-boot-sample-web-static[spring-boot-sample-web-static] |
| 186 | + -- A web application service static files |
| 187 | +* link:spring-boot-samples/spring-boot-sample-batch[spring-boot-sample-batch] |
| 188 | + -- Define and run a Batch job in a few lines of code |
| 189 | +* link:spring-boot-samples/spring-boot-sample-data-jpa[spring-boot-sample-data-jpa] |
| 190 | + -- Spring Data JPA + Hibernate + HSQLDB |
| 191 | +* link:spring-boot-samples/spring-boot-sample-integration[spring-boot-sample-integration] |
| 192 | + -- A spring integration application |
| 193 | +* link:spring-boot-samples/spring-boot-sample-profile[spring-boot-sample-profile] |
| 194 | + -- example showing Spring's `@profile` support |
| 195 | +* link:spring-boot-samples/spring-boot-sample-traditional[spring-boot-sample-traditional] |
| 196 | + -- shows more traditional WAR packaging (but also executable using `java -jar`) |
| 197 | +* link:spring-boot-samples/spring-boot-sample-xml[spring-boot-sample-xml] |
| 198 | + -- Example show how Spring Boot can be mixed with traditional XML configuration (we |
| 199 | + generally recommend using Java `@Configuration` whenever possible) |
| 200 | + |
| 201 | + |
| 202 | + |
| 203 | +== Guides |
| 204 | +The http://spring.io/[spring.io] site contains several guides that show how to use Spring |
| 205 | +Boot step-by-step: |
| 206 | + |
| 207 | +* http://spring.io/guides/gs/spring-boot/[Building an Application with Spring Boot] is a |
| 208 | + very basic guide that shows you how to create a simple application, run it and add some |
| 209 | + management services. |
| 210 | +* http://spring.io/guides/gs/actuator-service/[Building a RESTful Web Service with Spring |
| 211 | + Boot Actuator] is a guide to creating a REST web service and also shows how the server |
| 212 | + can be configured. |
| 213 | +* http://spring.io/guides/gs/convert-jar-to-war/[Converting a Spring Boot JAR Application |
| 214 | + to a WAR] shows you how to run applications in a web server as a WAR file. |
0 commit comments