-
Notifications
You must be signed in to change notification settings - Fork 42.1k
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 branch should be built with JDK 25. All 3.* branches need 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. We recommend Bellsoft Liberica. If you have SDKMAN! installed, it can be used to provision the recommended JDK using the repositoryâs .sdkmanrc files.
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-03as 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.setupfrom 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".
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