Creating a Spring Boot Application

I’ve created this section in Dec 2022 as I noticed since Spring Boot version 3.x was introduced, it requires us to use JDK 17 as a minimum.

Spring Boot Initializer

Load the Spring Boot template creation page at https://start.spring.io/

../../_images/initializr01.png

Select “Java”, “Maven” and version 2.x if you are using a JDK less than version 17.

You should only select version 3.x if you have Java JDK version 17 or higher.

../../_images/initializr02.png

Ensure you pick the JDK version that matches your IDE

Once you’ve got the Spring Boot version and JDK versions correctly selected to match your IDE, select the required dependencies.

The minimum dependency for a rest controller would be the “Spring Web” library. Then download the zip file and unzip the contents to your source code project folder.

Using IntelliJ IDE

  • I use the IntelliJ community version. Once you’ve unzipped the initializer zip file into your project folder, open up IntelliJ and “Open” the folder for a new project.

  • Open up the pom.xml and ensure that the Java version is correctly configured.

../../_images/pom-xml-jdk-version.png

Ensure the java version in the pom.xml file is correct

../../_images/maven-run-config.png

Set the Run parameter to “spring-boot:run” for Maven

  • Once the above two configurations are correct, you can start the Spring Boot application with “Shift F10”.