Getting started with Spring Boot
Before writing any codes, you have to prepare the development environment in your local system. The backend APIs is built with Spring Boot, so you should prepare a Java development environment.
Prerequisites
Firstly you should get a OpenJDK redistribution installed in your system.
Java 11
According to the latest Java trends report from Jetbrains, currently the most widely-used Java version is Java 8, next is Java 11.
Oracle had ended security updates of Java 8 in the early 2019. For those want to use Java 8 in production, you have to subscribe Oracle commercial support, or switch to other redistributions.
Oracle changed Java release progress and tried to accelerate the Java release cycles to very six months. And the next long term support version is Java 11, which is recommended to use in commercial products.
In this book, we will use Java 11 as Java development environment. Aligned with Spring Boot 2.2, we will try to use the latest Java language feature from Java 8 to Java 11.
You can download one of the following JDK 11 redistribution, and get it installed into your system.
Additionally, Azul, Amazon, Alibaba, and Microsoft have maintained their own OpenJDK redistribution for their products.
I prefer AdoptOpenJDK, because AdoptOpenJDK is maintained by Java communities.
Optionally, you can set JAVA_HOME environment variable and add <JDK installation dir>/bin in your PATH environment variable.
Open your terminal, execute the following command to verify your Java environment installed successfully.
#java -version
openjdk version "11.0.4" 2019-07-16
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.4+11)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.4+11, mixed mode)
Apache Maven
Apache Maven and Gradle are the most popular build tools in the Java communities.
Personally, I prefer Apache Maven.
Download the latest Apache Maven from http://maven.apache.org, and extract the files into your local system.
Optionally, you can set M2_HOME environment variable, and also do not forget to append <Maven Installation dir>/bin your PATH environment variable.
Type the following command to verify Apache Maven is working.
#mvn -v
Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-05T03:00:29+08:00)
Maven home: D:\build\maven\bin\..
Java version: 11.0.4, vendor: AdoptOpenJDK, runtime: D:\jdk11
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
Gradle (Optional)
If you are a Gradle fan, get it from Gradle website, and install it into your system.
gradle -v
Welcome to Gradle 5.5.1!
Here are the highlights of this release:
- Kickstart Gradle plugin development with gradle init
- Distribute organization-wide Gradle properties in custom Gradle distributions
- Transform dependency artifacts on resolution
For more details see https://docs.gradle.org/5.5.1/release-notes.html
------------------------------------------------------------
Gradle 5.5.1
------------------------------------------------------------
Build time: 2019-07-10 20:38:12 UTC
Revision: 3245f748c7061472da4dc184991919810f7935a5
Kotlin: 1.3.31
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.14 compiled on March 12 2019
JVM: 11.0.4 (AdoptOpenJDK 11.0.4+11)
OS: Windows 10 10.0 amd64
Java IDE
The most popular integration development environment in Java communities includes:
The most popular Java IDE is Intellij IDEA from Jetbrains . The free and open-source community edition includes basic language supports for Java, Kotlin, Groovy, etc.. If you want to get more features, buy a commercial license of the ultimate edition.
The refactored Spring Tools 4 supports Eclipse, VS Code, Eclipse Theia, get it from Spring website.
Apache NetBeans have just graduated from Apache incubator, it is still a great Java IDE. To get better Spring Boot support , install NbSpringBoot plugin from NetBeans plugin portal please.
You can choose your favorite one to write Java codes.
Last updated
Was this helpful?