A while ago, I wanted to learn how to create REST APIs with , a popular Java framework used by companies such as Netflix, Walmart, PayPal, Udemy, and many others. I had some experience building REST APIs with libraries like Jersey, Jetty, and Jackson, but I wanted to try Spring Boot. Spring Boot You can use a tool called Spring Initializr to generate the initial Spring Boot boilerplate code by accessing it through an online form. The form creates a zip file that contains the basic project structure and configuration. To use Spring Initializr: Go to , where you can find the Spring Initializr web tool. start.spring.io Fill out the form, specifying your desired build tool, programming language, Spring Boot version, project metadata, and dependencies. Click the button at the bottom of the screen to download the autogenerated code as a zip file. GENERATE Extract the contents of this zip file. The Spring Initializr Form Options At first, the many options available on the Spring Initializr form can be overwhelming. The following sections offer explanations for each form option and suggestions on which choices to make for your project. The Project Option The project option allows you to choose a build tool for your project. The purpose of build tools is to automate and manage the process of building software projects, which includes tasks like handling external dependencies, compiling source code, running tests, and packaging everything into distributable formats, like . There are three options: JARs Gradle – Groovy Gradle – Kotlin Maven has two options because it can use a (DSL) based on Groovy or Kotlin. If you have used Gradle before but are still confused about the difference, you may have been using Groovy as the DSL without knowing it since it is Gradle’s original DSL. Gradle domain-specific language If you do not know which option to pick, I would suggest Gradle because working with a DSL is more pleasant than XML, in my opinion. To better understand the differences between Gradle and , consider reading for more information. Maven this summary The Language Option The language option lets you choose a -compatible programming language for your Spring Boot project. There are three options: JVM Java Kotlin Groovy If you are not familiar with Kotlin or Groovy, Java is what you want. The Spring Boot Option The Spring Boot option enables you to select the version of Spring Boot to use in your project. It’s important to note that Spring Boot 2.x.x and 3.x.x are distinct . If you are starting a new Spring Boot project, I recommend choosing a stable 3.x.x version. major versions Also, note that some versions may be labeled M1, M2, RC1, or SNAPSHOT, indicating they are pre-release versions and not considered stable or production-ready. Be careful when using these versions, as they may contain bugs or incomplete features due to being in active development. The Project Metadata Options The project metadata options enable you to choose configuration details and settings for your project. There are seven metadata fields: – The unique identifier of your organization or project, typically written in . It helps to ensure that your package names do not conflict with packages from other organizations or projects. If you are creating a personal project, feel free to leave it as . Group reversed domain name notation com.example – The name of the archive generated by your build tool. The artifact usually has the same value as the name field below. Artifact – The name used for the project’s root directory, as well as the default name of the main application class. Name – A field that provides a short description of the project. Description – The name of the package generated Java classes will be placed in. The package name should be a combination of the group and name fields above (e.g., ). Package name com.example.myproject – Packaging refers to the type of archive your build tool will generate. Two common packaging types are JAR (Java Archive) and (Web Archive). JAR files are usually used for standalone applications, libraries, and command-line tools, while WAR files are used for web applications intended for deployment to a web server. I do not have a general recommendation here because it depends on your use case. Packaging WAR – The Java version for this project. If using Spring Boot version 3.x.x, the Java version must be 17+. Java The Dependency Option The dependency option allows you to select common dependencies used in Spring Boot projects that will be added to your project’s if you are using Gradle, or if you are using Maven. Some popular dependencies include: build.gradle pom.xml – provides annotations to reduce boilerplate code in Java classes. Lombok Lombok – provides functionality to build web applications, including support for RESTful web services and MVC architecture. Spring Web Spring Web – is a server-side template engine that allows for the creation of dynamic web pages by defining templates using HTML. Thymeleaf Thymeleaf – is a security framework that provides authentication, authorization, and other security features. Spring Security Spring Security – provides a simple way to interact with relational databases through the Java Persistence API (JPA) by generating boilerplate code for database operations. Spring Data JPA Spring Data JPA You can start by adding Spring Web if you want to keep things simple. As you build your application, you can add anything else you need. The Spring Boot Folder Structure When you extract the zip file created by Spring Initializr, you should end up with a folder structure that looks something like this (if you chose Maven as your build tool, it will look slightly different): . └── demo/ └── demo/ ├── .gradle/ │ └── ... ├── gradle/ │ └── ... ├── src/ │ ├── main/ │ │ ├── java/com/example/demo/ │ │ │ └── DemoApplication.java │ │ └── resources/ │ │ └── ... │ └── test/ │ └── java/com/example/demo/ │ └── DemoApplicationTests.java ├── .gitignore ├── build.gradle ├── gradlew ├── gradlew.bat ├── HELP.md └── settings.gradle If you look carefully, you may notice the outer folder contains another folder, also called . You can remove the outer folder to simplify the folder structure to: demo demo . └── demo/ ├── .gradle/ │ └── ... ├── gradle/ │ └── ... ├── src/ │ ├── main/ │ │ ├── java/com/example/demo/ │ │ │ └── DemoApplication.java │ │ └── resources/ │ │ └── ... │ └── test/ │ └── java/com/example/demo/ │ └── DemoApplicationTests.java ├── .gitignore ├── build.gradle ├── gradlew ├── gradlew.bat ├── HELP.md └── settings.gradle Let’s take a moment to understand what these generated files and folders are: – This is where Gradle stores its project-specific cache. .gradle/ – This contains the JAR file and configuration of the . gradle/ Gradle Wrapper – This contains the main source code for your application. Initially, it contains one source code file, , the entry point for your Spring Boot project, and the directory, where configuration files, static assets, and HTML templates would be. src/main/ DemoApplication.java resources/ – This contains the test code for your application. Initially, it contains one test file, , which contains a trivial test. src/test/ DemoApplicationTests.java – This specifies which files and folders should be ignored by . .gitignore Git – This is the Gradle build script for your project, which defines your project’s dependencies, plugins, and other build settings. build.gradle – This is a wrapper that allows you to build your Spring Boot project without already having Gradle on your system. gradlew shell script – This is a that does the same thing as but in the Windows command prompt. gradlew.bat batch script gradlew – This is just a with some references, guides, and additional links. Feel free to delete this file. HELP.md markdown file – This is mostly used for . For your Spring Boot project, it will likely just contain the name of your project. settings.gradle multi-project builds As you can see, most of the files and folders above are from Gradle. If you want to learn more about what these are for, I encourage you to go to the . Gradle documentation Conclusion Congratulations! You now have a better understanding of Spring Initializr and how to use it to create Spring Boot applications. You also have an idea of what the various files and folders autogenerated by Spring Initializr do. Now it is time to open up your favorite text editor or IDE and start coding! Also published . here