66If you are getting started with Spring Boot, or "Spring" in general, start by reading
77this section. It answers the basic "`what?`", "`how?`" and "`why?`" questions. It includes
88an introduction to Spring Boot, along with installation instructions.
9- We then walk you through building your first Spring Boot application, discussing some core principles as
10- we go.
9+ We then walk you through building your first Spring Boot application, discussing some core
10+ principles as we go.
1111--
1212
1313
1414[[getting-started-introducing-spring-boot]]
1515== Introducing Spring Boot
1616Spring Boot makes it easy to create stand-alone, production-grade Spring based
1717Applications that you can run. We take an opinionated view of the Spring
18- platform and third-party libraries, so that you can get started with minimum fuss. Most Spring
19- Boot applications need very little Spring configuration.
18+ platform and third-party libraries, so that you can get started with minimum fuss. Most
19+ Spring Boot applications need very little Spring configuration.
2020
21- You can use Spring Boot to create Java applications that can be started by using `java -jar`
22- or more traditional war deployments. We also provide a command line tool that runs
23- "`spring scripts`".
21+ You can use Spring Boot to create Java applications that can be started by using
22+ `java -jar` or more traditional war deployments. We also provide a command line tool that
23+ runs "`spring scripts`".
2424
2525Our primary goals are:
2626
@@ -29,7 +29,8 @@ Spring development.
2929* Be opinionated out of the box but get out of the way quickly as requirements start to
3030diverge from the defaults.
3131* Provide a range of non-functional features that are common to large classes of projects
32- (such as embedded servers, security, metrics, health checks, and externalized configuration).
32+ (such as embedded servers, security, metrics, health checks, and externalized
33+ configuration).
3334* Absolutely no code generation and no requirement for XML configuration.
3435
3536
@@ -74,18 +75,18 @@ begin, you should check your current Java installation by using the following co
7475----
7576
7677If you are new to Java development or if you want to experiment with Spring Boot,
77- you might want to try the <<getting-started-installing-the-cli, Spring Boot CLI>> (Command Line Interface) first,
78- otherwise, read on for "`classic`" installation instructions.
78+ you might want to try the <<getting-started-installing-the-cli, Spring Boot CLI>> (Command
79+ Line Interface) first, otherwise, read on for "`classic`" installation instructions.
7980
8081
8182
8283[[getting-started-installation-instructions-for-java]]
8384=== Installation Instructions for the Java Developer
84- You can use Spring Boot in the same way as any standard Java library. To do so, include the
85- appropriate `+spring-boot-*.jar+` files on your classpath. Spring Boot does not require
86- any special tools integration, so you can use any IDE or text editor. Also, there is
87- nothing special about a Spring Boot application, so you can run and debug a Spring Boot application as you would
88- any other Java program.
85+ You can use Spring Boot in the same way as any standard Java library. To do so, include
86+ the appropriate `+spring-boot-*.jar+` files on your classpath. Spring Boot does not
87+ require any special tools integration, so you can use any IDE or text editor. Also, there
88+ is nothing special about a Spring Boot application, so you can run and debug a Spring Boot
89+ application as you would any other Java program.
8990
9091Although you _could_ copy Spring Boot jars, we generally recommend that you use a
9192build tool that supports dependency management (such as Maven or Gradle).
@@ -191,8 +192,9 @@ can follow the instructions at http://www.gradle.org/.
191192Spring Boot dependencies can be declared by using the `org.springframework.boot` `group`.
192193Typically, your project declares dependencies to one or more
193194<<using-spring-boot.adoc#using-boot-starter, "`Starters`">>. Spring Boot
194- provides a useful <<build-tool-plugins.adoc#build-tool-plugins-gradle-plugin, Gradle plugin>>
195- that can be used to simplify dependency declarations and to create executable jars.
195+ provides a useful <<build-tool-plugins.adoc#build-tool-plugins-gradle-plugin, Gradle
196+ plugin>> that can be used to simplify dependency declarations and to create executable
197+ jars.
196198
197199.Gradle Wrapper
198200****
@@ -251,8 +253,8 @@ endif::[]
251253
252254[[getting-started-installing-the-cli]]
253255=== Installing the Spring Boot CLI
254- The Spring Boot CLI (Command Line Interface) is a command line tool that you can use to quickly
255- prototype with Spring. It lets you run http://groovy-lang.org/[Groovy] scripts,
256+ The Spring Boot CLI (Command Line Interface) is a command line tool that you can use to
257+ quickly prototype with Spring. It lets you run http://groovy-lang.org/[Groovy] scripts,
256258which means that you have a familiar Java-like syntax without so much boilerplate code.
257259
258260You do not need to use the CLI to work with Spring Boot, but it is definitely the quickest
@@ -267,8 +269,8 @@ You can download the Spring CLI distribution from the Spring software repository
267269* http://repo.spring.io/{spring-boot-repo}/org/springframework/boot/spring-boot-cli/{spring-boot-version}/spring-boot-cli-{spring-boot-version}-bin.zip[spring-boot-cli-{spring-boot-version}-bin.zip]
268270* http://repo.spring.io/{spring-boot-repo}/org/springframework/boot/spring-boot-cli/{spring-boot-version}/spring-boot-cli-{spring-boot-version}-bin.tar.gz[spring-boot-cli-{spring-boot-version}-bin.tar.gz]
269271
270- Cutting edge http://repo.spring.io/snapshot/org/springframework/boot/spring-boot-cli/[snapshot distributions]
271- are also available.
272+ Cutting edge http://repo.spring.io/snapshot/org/springframework/boot/spring-boot-cli/[snapshot
273+ distributions] are also available.
272274
273275Once downloaded, follow the {github-raw}/spring-boot-project/spring-boot-cli/src/main/content/INSTALL.txt[INSTALL.txt]
274276instructions from the unpacked archive. In summary, there is a `spring` script
@@ -363,9 +365,10 @@ The Spring Boot CLI includes scripts that provide command completion for
363365the http://en.wikipedia.org/wiki/Bash_%28Unix_shell%29[BASH] and
364366http://en.wikipedia.org/wiki/Zsh[zsh] shells. You can `source` the script (also named
365367`spring`) in any shell or put it in your personal or system-wide bash completion
366- initialization. On a Debian system, the system-wide scripts are in `/shell-completion/bash`
367- and all scripts in that directory are executed when a new shell starts. For example, to run the script
368- manually if you have installed using SDKMAN!, use the following commands:
368+ initialization. On a Debian system, the system-wide scripts are in
369+ `/shell-completion/bash` and all scripts in that directory are executed when a new shell
370+ starts. For example, to run the script manually if you have installed using SDKMAN!, use
371+ the following commands:
369372
370373[indent=0]
371374----
@@ -432,9 +435,9 @@ update your `PATH` environment variable to remove any older references.
432435
433436[[getting-started-first-application]]
434437== Developing Your First Spring Boot Application
435- This section describes how to develop a simple "`Hello World!`" web application that highlights some
436- of Spring Boot's key features. We use Maven to build this project, since most IDEs
437- support it.
438+ This section describes how to develop a simple "`Hello World!`" web application that
439+ highlights some of Spring Boot's key features. We use Maven to build this project, since
440+ most IDEs support it.
438441
439442[TIP]
440443====
@@ -444,12 +447,12 @@ that use Spring Boot. If you need to solve a specific problem, check there first
444447You can shortcut the steps below by going to https://start.spring.io and choosing the
445448"Web" starter from the dependencies searcher. Doing so generates a new
446449project structure so that you can <<getting-started-first-application-code,start coding
447- right away>>. Check the https://github.com/spring-io/initializr[Spring Initializr documentation] for
448- more details.
450+ right away>>. Check the https://github.com/spring-io/initializr[Spring Initializr
451+ documentation] for more details.
449452====
450453
451- Before we begin, open a terminal and run the following commands to ensure that you have valid versions of Java and Maven
452- installed:
454+ Before we begin, open a terminal and run the following commands to ensure that you have
455+ valid versions of Java and Maven installed:
453456
454457[indent=0]
455458----
@@ -523,8 +526,9 @@ endif::[]
523526 </project>
524527----
525528
526- The preceding listing should give you a working build. You can test it by running `mvn package` (for
527- now, you can ignore the "`jar will be empty - no content was marked for inclusion!`" warning).
529+ The preceding listing should give you a working build. You can test it by running
530+ `mvn package` (for now, you can ignore the "`jar will be empty - no content was marked for
531+ inclusion!`" warning).
528532
529533NOTE: At this point, you could import the project into an IDE (most modern Java IDEs
530534include built-in support for Maven). For simplicity, we continue to use a plain
@@ -553,10 +557,10 @@ currently have by running the following command:
553557 [INFO] com.example:myproject:jar:0.0.1-SNAPSHOT
554558----
555559
556- The `mvn dependency:tree` command prints a tree representation of your project dependencies.
557- You can see that `spring-boot-starter-parent` provides no
558- dependencies by itself. To add the necessary dependencies, edit your `pom.xml` and add the `spring-boot-starter-web` dependency
559- immediately below the `parent` section:
560+ The `mvn dependency:tree` command prints a tree representation of your project
561+ dependencies. You can see that `spring-boot-starter-parent` provides no
562+ dependencies by itself. To add the necessary dependencies, edit your `pom.xml` and add the
563+ `spring-boot-starter-web` dependency immediately below the `parent` section:
560564
561565[source,xml,indent=0,subs="verbatim,quotes,attributes"]
562566----
@@ -575,9 +579,9 @@ additional dependencies, including the Tomcat web server and Spring Boot itself.
575579
576580[[getting-started-first-application-code]]
577581=== Writing the Code
578- To finish our application, we need to create a single Java file. By default, Maven compiles sources
579- from `src/main/java`, so you need to create that folder structure and then add a
580- file named `src/main/java/Example.java` to contain the following code:
582+ To finish our application, we need to create a single Java file. By default, Maven
583+ compiles sources from `src/main/java`, so you need to create that folder structure and
584+ then add a file named `src/main/java/Example.java` to contain the following code:
581585
582586[source,java,indent=0]
583587----
@@ -619,8 +623,8 @@ that any HTTP request with the `/` path should be mapped to the `home` method. T
619623back to the caller.
620624
621625TIP: The `@RestController` and `@RequestMapping` annotations are Spring MVC annotations.
622- (They are not specific to Spring Boot.) See the {spring-reference}web.html#mvc[MVC section] in
623- the Spring Reference Documentation for more details.
626+ (They are not specific to Spring Boot.) See the {spring-reference}web.html#mvc[MVC
627+ section] in the Spring Reference Documentation for more details.
624628
625629
626630
@@ -702,9 +706,9 @@ themselves contained within a jar). This can be problematic if you are looking t
702706distribute a self-contained application.
703707
704708To solve this problem, many developers use "`uber`" jars. An uber jar packages
705- all the classes from all the application's dependencies into a single archive. The problem with this approach is that
706- it becomes hard to see which libraries are in your application. It can
707- also be problematic if the same filename is used (but with different content) in
709+ all the classes from all the application's dependencies into a single archive. The problem
710+ with this approach is that it becomes hard to see which libraries are in your application.
711+ It can also be problematic if the same filename is used (but with different content) in
708712multiple jars.
709713
710714Spring Boot takes a <<appendix-executable-jar-format.adoc#executable-jar, different
@@ -753,7 +757,8 @@ Save your `pom.xml` and run `mvn package` from the command line, as follows:
753757----
754758
755759If you look in the `target` directory, you should see `myproject-0.0.1-SNAPSHOT.jar`. The
756- file should be around 10 MB in size. If you want to peek inside, you can use `jar tvf`, as follows:
760+ file should be around 10 MB in size. If you want to peek inside, you can use `jar tvf`, as
761+ follows:
757762
758763[indent=0]
759764----
0 commit comments