From today we are going to start a new tutorial series on spring boot and this is the first tutorial of this series entitled “Java Spring Boot – Start Project”. We will develop a blog API in spring boot where we will implement all CRUD operation but in this part, we only start the project. Before starting this series, I suggest you look at initial set up. First of all, visit the following Spring Initializr link.
There are two different options. The left side contains the project configuration and metadata. The right side contains framework dependencies. Select the configuration and add project metadata in the project initializr page. We also need to add some dependencies as we are going to develop REST API. My configuration is like the following image.
After configuring the project, now click on the generate button. It will download a zip file named
myproject.zip containing project files in another folder named
myproject. unzip the folder in a directory you want.
Open the project in your favorite text editor or IDE like sublime text or IntelliJ IDEA. Our project structure is like the below image.
We can add more dependencies in the pom.xml file and we also can add application property in application.properties file of resources directory.
Before running the project, we need to import the dependencies declared in the pom.xml file. Now we run the application using the command prompt. Open the command prompt or powershell window in the folder where pom.xml is existed and run the following command.
Project will run under tomcat server in port 8080 with http protocol. Now we can access the project using http://127.0.0.1:8080 or http://localhost:8080.
When we hit the URL first of all it executes the main method from MyProjectApplication.java file. In the main method, spring boot runs a thread of SpringBootApplication class. So we need to add the @SpringBootApplication annotation if it does not exist.
This is the end of this tutorial. In the next tutorial we will learn REST CRUD operation with some simple data. Have good day! Bye!