This is an introductory tutorial for the Spring Boot world applications. We will explain what Spring Boot is, why it is useful and popular and we will have a short tutorial to see how to generate and start a simple application.
Spring Boot is a tool that makes it easy to build Java applications. It’s part of the Spring Framework and it has the goal of taking away a lot of the hard setup work so you can start coding quickly. It’s like a shortcut for building apps!
There are a lot of reasons why Spring Boot is very popular in the development world, but the main ones are:
At the moment, we should know that Spring Boot:
You can use Spring Initializr to quickly generate a Spring Boot project with Maven or Gradle. We can use the following configurations:
You will receive a ready-to-use project. All the configurations are already written in the build.gradle file and the start ExplainjavaApplication class is already created.
Additionally, we also have an already created structure in the resources folder and a test package.
You only need to run the gradle command bootRun to start the application. You can do this by writing it in the command line in the project root or using the Gradle tab from Intelij IDE.
When the command is called, Spring Boot starts an embedded server (in our case Tomcat) on a default port (8080). That means that we started a web application on our computer and we can access it by writing localhost:8080 in the browser. For now, we will not receive anything, but we can write some code to solve this problem.
To test our application, we can create a new class HelloController in a new package called “controller”. The class should look like this:
@RestController
public class HelloController {
@GetMapping("/hello")
public String sayHello() {
return "Hello, this is a 'Explain Java like I'm 8' tutorial";
}
}
Now, when you access localhost:8080/hello, you will receive the String “Hello, this is a ‘Explain Java like I’m 8’ tutorial”. You can test it by accessing the URL through your browser.
In this tutorial we had a short introduction to Spring Boot. In the future tutorials, we will talk about how to create a REST API using Spring Boot, how to connect it with a database, how to create secure applications and many, many more!
Learn advanced concepts, work on real-world projects, and fast-track your journey to becoming a proficient Java developer. Start now and unlock your full potential in the world of Java programming!
Start now and unlock your full potential in the world of Java programming!
The place where you can start your Java journey.
© All Rights Reserved.