-
Notifications
You must be signed in to change notification settings - Fork 40.7k
Working with the Code
See the CONTRIBUTING
file in the repository for information on how to contribute issues and code changes to the project.
Spring Boot source can be built from the command line using Gradle.
We include Gradle’s wrapper scripts (./gradlew
or gradlew.bat
) that you can run rather than needing to install Gradle locally.
The source on the main
and 3.0.x
branch should be built with JDK 17. Earlier branches should be built with JDK 1.8. A HotSpot JVM should be used as some integration tests rely on features that might not be available on OpenJ9 or other JVMs.
The project can be built from the root directory using the standard Gradle command:
$ ./gradlew build
Some integration tests that run as part of the Spring Boot build rely on a Docker daemon to test against live services using Testcontainers or to test build plugin features. These tests will automatically be disabled if a local Docker daemon is not available. If a local Docker daemon is running, the tests may fail if there are insufficient resources allocated to the Docker daemon. The integration tests may require 20 GB of disk image size or more to be allocated to the Docker daemon.
The reference documentation is stored in this repository, see spring-boot-project/spring-boot-docs/src/docs/asciidoc
.
We use Asciidoc and you can build the documentation locally using this command:
$ ./gradlew spring-boot-project:spring-boot-docs:asciidoc
Note
|
The generated HTML documentation is available from spring-boot-project/spring-boot-docs/build/docs/asciidoc/ .
|
If you don’t have an IDE preference we would recommend that you use Spring Tool Suite or Eclipse when working with the code. We use the Buildship Eclipse plugin for Gradle support. Other IDEs and tools should also work without issue.
You can import the Spring Boot code into any Eclipse 2021-03-based distribution.
The easiest way to setup a new environment is to use the Eclipse Installer with the provided spring-boot-project.setup
file (in the /eclipse
folder).
Spring Boot includes a .setup
files which can be used with the Eclipse Installer to provision a new environment.
To use the installer:
-
Download and run the latest Eclipse Installer (must be 1.19.0 or above).
-
Switch to "Advanced Mode" using the drop down menu on the right.
-
Select “Eclipse IDE for Java Developers” under “Eclipse.org” as the product to install,
2021-03
as the product version, and click “next”. -
For the “Project” click on “+” to add a new setup file. Select “Github Projects” and browse for
<checkout>/eclipse/spring-boot-project.setup
from your locally cloned copy of the source code. Click “OK” to add the setup file to the list. -
Double-click on “Spring Boot” from the project list to add it to the list that will be provisioned then click “Next”.
-
Click show all variables and make sure that “Checkout Location” points to the locally cloned source code that you selected earlier. You might also want to pick a different install location here.
-
Click “Finish” to install the software.
Once complete you should find that a local workspace has been provisioned complete with all required Eclipse plugins. Projects will be grouped into working-sets to make the code easier to navigate.
Tip
|
If you see import errors with com.sun packages make sure you have setup a valid JavaSE-1.8 environment. From preferences select “Java”, “Installed JREs”, “Execution Environments” and make sure “JavaSE-1.8” points to a Java 1.8 install (we use AdoptOpenJDK on our CI).
|
If you prefer to install Eclipse yourself you should use the Buildship Eclipse plugin. If you don’t already have Buildship installed it is available from the “Eclipse marketplace”.
Spring Boot includes project specific source formatting settings, in order to have these work with Buildship, we provide an additional Eclipse plugin that you can install.
-
Select “Help” → “Install New Software”.
-
Add
https://repo.spring.io/javaformat-eclipse-update-site/
as a site. -
Install "Spring Java Format".
Note
|
The plugin is optional. Projects can be imported without the plugins, your code changes just won’t be automatically formatted. |
With the requisite Eclipse plugins installed you can select Gradle → Existing Gradle project
from the File → Import…
menu to import the code.
The repository contains a .idea
folder with useful settings such as code style, copyright headers. These are taken into account automatically.
If you have performed a checkout of this repository already, use “File” → “Open” and then select the root build.gradle
file to import the code.
Alternatively, you can let IntelliJ IDEA checkout the code for you. Use “File” → “New” → “Project from Version Control” and https://github.com/spring-projects/spring-boot
for the URL.
Once the checkout has completed, a pop-up will suggest to open the project.
If you haven’t done so, install the formatter plugin so that proper formatting rules are applied automatically when you reformat code in the IDE.
-
Download the latest IntelliJ IDEA plugin.
-
Select “IntelliJ IDEA” → “Preferences”.
-
Select “Plugins”.
-
Select the wheel and “Install Plugin from Disk…”.
-
Select the jar file you’ve downloaded.
Gradle is well supported by most Java IDEs. Refer to your vendor documentation.
Some files in the git repository may exceed the Windows maximum file path (260 characters), depending on where you clone the repository.
If you get Filename too long
errors, set the core.longPaths=true
git option:
git clone -c core.longPaths=true https://github.com/spring-projects/spring-boot