The following embedded servlet containers are supported out of the box:
|===
@ -65,51 +65,51 @@ You can also deploy Spring Boot applications to any Servlet 3.0+ compatible cont
@@ -65,51 +65,51 @@ You can also deploy Spring Boot applications to any Servlet 3.0+ compatible cont
[[getting-started-installing-spring-boot]]
== Installing Spring Boot
Spring Boot can be used with "`classic`" Java development tools or installed as a command
line tool. Regardless, you will need http://www.java.com[Java SDK v1.8] or higher. You
should check your current Java installation before you begin:
line tool. Either way, you need http://www.java.com[Java SDK v1.8] or higher. Before you
begin, you should check your current Java installation by using the following command:
[indent=0]
----
$ java -version
----
If you are new to Java development, or if you just want to experiment with Spring Boot
you might want to try the <<getting-started-installing-the-cli, Spring Boot CLI>> first,
If you are new to Java development or if you want to experiment with Spring Boot,
you might want to try the <<getting-started-installing-the-cli, Spring Boot CLI>> (Command Line Interface) first,
otherwise, read on for "`classic`" installation instructions.
TIP: The `spring-boot-starter-parent` is a great way to use Spring Boot, but it might
not be suitable all of the time. Sometimes you may need to inherit from a different
parent POM, or you might just not like our default settings. See
parent POM, or you might not like our default settings. In those cases, see
<<using-boot-maven-without-a-parent>> for an alternative solution that uses an `import`
scope.
[[getting-started-gradle-installation]]
==== Gradle installation
Spring Boot is compatible with Gradle 4. If you don't already have Gradle installed you
==== Gradle Installation
Spring Boot is compatible with Gradle 4. If you do not already have Gradle installed, you
can follow the instructions at http://www.gradle.org/.
Spring Boot dependencies can be declared using the `org.springframework.boot` `group`.
Typically your project will declare dependencies to one or more
Spring Boot dependencies can be declared by using the `org.springframework.boot` `group`.
Typically, your project declares dependencies to one or more
<<using-spring-boot.adoc#using-boot-starter, "`Starters`">>. Spring Boot
provides a useful <<build-tool-plugins.adoc#build-tool-plugins-gradle-plugin, Gradle plugin>>
that can be used to simplify dependency declarations and to create executable jars.
@ -197,7 +197,7 @@ that can be used to simplify dependency declarations and to create executable ja
@@ -197,7 +197,7 @@ that can be used to simplify dependency declarations and to create executable ja
.Gradle Wrapper
****
The Gradle Wrapper provides a nice way of "`obtaining`" Gradle when you need to build a
project. It's a small script and library that you commit alongside your code to bootstrap
project. It is a small script and library that you commit alongside your code to bootstrap
the build process. See {gradle-user-guide}/gradle_wrapper.html for details.
Once downloaded, follow the {github-raw}/spring-boot-project/spring-boot-cli/src/main/content/INSTALL.txt[INSTALL.txt]
instructions from the unpacked archive. In summary: there is a `spring` script
(`spring.bat` for Windows) in a `bin/` directory in the `.zip` file, or alternatively you
instructions from the unpacked archive. In summary, there is a `spring` script
(`spring.bat` for Windows) in a `bin/` directory in the `.zip` file. Alternatively, you
can use `java -jar` with the `.jar` file (the script helps you to be sure that the
classpath is set correctly).
@ -282,7 +282,7 @@ classpath is set correctly).
@@ -282,7 +282,7 @@ classpath is set correctly).
==== Installation with SDKMAN!
SDKMAN! (The Software Development Kit Manager) can be used for managing multiple versions of
various binary SDKs, including Groovy and the Spring Boot CLI.
Get SDKMAN! from http://sdkman.io and install Spring Boot with
Get SDKMAN! from http://sdkman.io and install Spring Boot by using the following commands:
[indent=0,subs="verbatim,quotes,attributes"]
----
@ -291,8 +291,8 @@ Get SDKMAN! from http://sdkman.io and install Spring Boot with
@@ -291,8 +291,8 @@ Get SDKMAN! from http://sdkman.io and install Spring Boot with
Spring Boot v{spring-boot-version}
----
If you are developing features for the CLI and want easy access to the version you just
built, follow these extra instructions.
If you are developing features for the CLI and want easy access to the version you
built, use the following commands:
[indent=0,subs="verbatim,quotes,attributes"]
----
@ -302,11 +302,11 @@ built, follow these extra instructions.
@@ -302,11 +302,11 @@ built, follow these extra instructions.
Spring CLI v{spring-boot-version}
----
This will install a local instance of `spring` called the `dev` instance.
The preceding instructions install a local instance of `spring` called the `dev` instance.
It points at your target build location, so every time you rebuild Spring
Boot, `spring` will be up-to-date.
Boot, `spring` is up-to-date.
You can see it by doing this:
You can see it by running the following command:
[indent=0,subs="verbatim,quotes,attributes"]
----
@ -328,9 +328,9 @@ You can see it by doing this:
@@ -328,9 +328,9 @@ You can see it by doing this:
[[getting-started-homebrew-cli-installation]]
==== OSX Homebrew installation
If you are on a Mac and using http://brew.sh/[Homebrew], all you need to do to install
the Spring Boot CLI is:
==== OSX Homebrew Installation
If you are on a Mac and use http://brew.sh/[Homebrew], you can install
the Spring Boot CLI by using the following commands:
[indent=0]
----
@ -338,17 +338,17 @@ the Spring Boot CLI is:
@@ -338,17 +338,17 @@ the Spring Boot CLI is:
$ brew install springboot
----
Homebrew will install `spring` to `/usr/local/bin`.
Homebrew installs `spring` to `/usr/local/bin`.
NOTE: If you don't see the formula, your installation of brew might be out-of-date.
Just execute `brew update` and try again.
NOTE: If you do not see the formula, your installation of brew might be out-of-date.
In that case, run `brew update` and try again.
[[getting-started-macports-cli-installation]]
==== MacPorts installation
If you are on a Mac and using http://www.macports.org/[MacPorts], all you need to do to
install the Spring Boot CLI is:
==== MacPorts Installation
If you are on a Mac and use http://www.macports.org/[MacPorts], you can
install the Spring Boot CLI by using the following command:
[indent=0]
----
@ -358,14 +358,14 @@ install the Spring Boot CLI is:
@@ -358,14 +358,14 @@ install the Spring Boot CLI is:
[[getting-started-cli-command-line-completion]]
==== Command-line completion
Spring Boot CLI ships with scripts that provide command completion for
http://en.wikipedia.org/wiki/Bash_%28Unix_shell%29[BASH] and
==== Command-line Completion
The Spring Boot CLI includes scripts that provide command completion for
the http://en.wikipedia.org/wiki/Bash_%28Unix_shell%29[BASH] and
http://en.wikipedia.org/wiki/Zsh[zsh] shells. You can `source` the script (also named
`spring`) in any shell, or put it in your personal or system-wide bash completion
initialization. On a Debian system the system-wide scripts are in `/shell-completion/bash`
and all scripts in that directory are executed when a new shell starts. To run the script
manually, e.g. if you have installed using SDKMAN!
`spring`) in any shell or put it in your personal or system-wide bash completion
initialization. On a Debian system, the system-wide scripts are in `/shell-completion/bash`
and all scripts in that directory are executed when a new shell starts. For example, to run the script
manually if you have installed using SDKMAN!, use the following commands:
[indent=0]
----
@ -374,15 +374,15 @@ manually, e.g. if you have installed using SDKMAN!
@@ -374,15 +374,15 @@ manually, e.g. if you have installed using SDKMAN!
grab help jar run test version
----
NOTE: If you install Spring Boot CLI using Homebrew or MacPorts, the command-line
NOTE: If you install the Spring Boot CLI by using Homebrew or MacPorts, the command-line
completion scripts are automatically registered with your shell.
[[getting-started-cli-example]]
==== Quick start Spring CLI example
Here's a really simple web application that you can use to test your installation. Create
a file called `app.groovy`:
==== Quick-start Spring CLI Example
You can use the following web application to test your installation. To start, create
=== Upgrading from an earlier version of Spring Boot
=== Upgrading from an Earlier Version of Spring Boot
If you are upgrading from an earlier release of Spring Boot check the "`release notes`"
hosted on the {github-wiki}[project wiki]. You'll find upgrade instructions along with
a list of "`new and noteworthy`" features for each release.
@ -431,25 +431,25 @@ update your `PATH` environment variable to remove any older references.
@@ -431,25 +431,25 @@ update your `PATH` environment variable to remove any older references.
[[getting-started-first-application]]
== Developing your first Spring Boot application
Let's develop a simple "`Hello World!`" web application in Java that highlights some
of Spring Boot's key features. We'll use Maven to build this project since most IDEs
== Developing Your First Spring Boot Application
This section describes how to develop a simple "`Hello World!`" web application that highlights some
of Spring Boot's key features. We use Maven to build this project, since most IDEs
support it.
[TIP]
====
The http://spring.io[spring.io] web site contains many "`Getting Started`" guides
that use Spring Boot. If you're looking to solve a specific problem, check there first.
The http://spring.io[spring.io] web site contains many "`Getting Started`" http://spring.io/guides[guides]
that use Spring Boot. If you need to solve a specific problem, check there first.
You can shortcut the steps below by going to https://start.spring.io and choosing the
"Web" starter from the dependencies searcher. This will automatically generate a new
"Web" starter from the dependencies searcher. Doing so generates a new
project structure so that you can <<getting-started-first-application-code,start coding
right away>>. Check the https://github.com/spring-io/initializr[documentation for
more details].
right away>>. Check the https://github.com/spring-io/initializr[Spring Initializr documentation] for
more details.
====
Before we begin, open a terminal to check that you have valid versions of Java and Maven
installed.
Before we begin, open a terminal and run the following commands to ensure that you have valid versions of Java and Maven
installed:
[indent=0]
----
@ -475,7 +475,7 @@ that you have created a suitable folder and that it is your "`current directory`
@@ -475,7 +475,7 @@ that you have created a suitable folder and that it is your "`current directory`
[[getting-started-first-application-pom]]
=== Creating the POM
We need to start by creating a Maven `pom.xml` file. The `pom.xml` is the recipe that
will be used to build your project. Open your favorite text editor and add the following:
is used to build your project. Open your favorite text editor and add the following:
Let's finish our example by creating a completely self-contained executable jar file that
=== Creating an Executable Jar
We finish our example by creating a completely self-contained executable jar file that
we could run in production. Executable jars (sometimes called "`fat jars`") are archives
containing your compiled classes along with all of the jar dependencies that your code
needs to run.
.Executable jars and Java
****
Java does not provide any standard way to load nested jar files (i.e. jar files that are
Java does not provide a standard way to load nested jar files (jar files that are
themselves contained within a jar). This can be problematic if you are looking to
distribute a self-contained application.
To solve this problem, many developers use "`uber`" jars. An uber jar simply packages
all classes, from all jars, into a single archive. The problem with this approach is that
it becomes hard to see which libraries you are actually using in your application. It can
To solve this problem, many developers use "`uber`" jars. An uber jar packages
all the classes from all the application's dependencies into a single archive. The problem with this approach is that
it becomes hard to see which libraries are in your application. It can
also be problematic if the same filename is used (but with different content) in
multiple jars.
@ -712,8 +711,8 @@ Spring Boot takes a <<appendix-executable-jar-format.adoc#executable-jar, differ
@@ -712,8 +711,8 @@ Spring Boot takes a <<appendix-executable-jar-format.adoc#executable-jar, differ
approach>> and allows you to actually nest jars directly.
****
To create an executable jar we need to add the `spring-boot-maven-plugin` to our
`pom.xml`. Insert the following lines just below the `dependencies` section:
To create an executable jar, we need to add the `spring-boot-maven-plugin` to our
`pom.xml`. To do so, insert the following lines just below the `dependencies` section:
@ -728,11 +727,11 @@ To create an executable jar we need to add the `spring-boot-maven-plugin` to our
@@ -728,11 +727,11 @@ To create an executable jar we need to add the `spring-boot-maven-plugin` to our
----
NOTE: The `spring-boot-starter-parent` POM includes `<executions>` configuration to
bind the `repackage` goal. If you are not using the parent POM you will need to declare
bind the `repackage` goal. If you do not use the parent POM, you need to declare
this configuration yourself. See the {spring-boot-maven-plugin-site}/usage.html[plugin
documentation] for details.
Save your `pom.xml` and run `mvn package` from the command line:
Save your `pom.xml` and run `mvn package` from the command line, as follows:
[indent=0,subs="attributes"]
----
@ -753,8 +752,8 @@ Save your `pom.xml` and run `mvn package` from the command line:
@@ -753,8 +752,8 @@ Save your `pom.xml` and run `mvn package` from the command line:
If you look in the `target` directory you should see `myproject-0.0.1-SNAPSHOT.jar`. The
file should be around 10 MB in size. If you want to peek inside, you can use `jar tvf`:
If you look in the `target` directory, you should see `myproject-0.0.1-SNAPSHOT.jar`. The
file should be around 10 MB in size. If you want to peek inside, you can use `jar tvf`, as follows:
[indent=0]
----
@ -765,7 +764,7 @@ You should also see a much smaller file named `myproject-0.0.1-SNAPSHOT.jar.orig
@@ -765,7 +764,7 @@ You should also see a much smaller file named `myproject-0.0.1-SNAPSHOT.jar.orig
in the `target` directory. This is the original jar file that Maven created before it was
repackaged by Spring Boot.
To run that application, use the `java -jar` command:
To run that application, use the `java -jar` command, as follows:
[indent=0,subs="attributes"]
----
@ -784,24 +783,24 @@ To run that application, use the `java -jar` command:
@@ -784,24 +783,24 @@ To run that application, use the `java -jar` command:
........ Started Example in 2.536 seconds (JVM running for 2.864)
----
As before, to gracefully exit the application hit `ctrl-c`.
As before, to exit the application, press `ctrl-c`.
[[getting-started-whats-next]]
== What to read next
Hopefully this section has provided you with some of the Spring Boot basics, and got you
on your way to writing your own applications. If you're a task-oriented type of
developer you might want to jump over to http://spring.io and check out some of the
== What to Read Next
Hopefully, this section provided some of the Spring Boot basics and got you
on your way to writing your own applications. If you are a task-oriented type of
developer, you might want to jump over to http://spring.io and check out some of the
http://spring.io/guides/[getting started] guides that solve specific
"`How do I do that with Spring`" problems; we also have Spring Boot-specific
"`How do I do that with Spring?`" problems. We also have Spring Boot-specific