Spring Boot (Building a web application - Running) - Part 2
This is the second part of our Spring Boot application.
- Spring Boot (Introduction) - Part 1
- Spring Boot (Building a web application - Running) - Part 2
- Spring Boot (Building a web application - JPA integration) - Part 3
- Spring Boot (Increasing your productivity with Spring devtools) - Part 4
- Spring Boot (Building a standalone library) - Part 5
- Spring Boot (Generating a FATJAR) - Part 6
- Spring Boot (Publishing at AWS) - Part 7
We have to create a new maven project. The IDE used on this tutorial will be Eclipse (Version: Oxygen.3a)
At the menu select: File>New>Other>Maven>Maven Project
Select: Create a simple project (skip archetype selection)
Click Next.
Full fill the group id filed and the artifact id, then click finish button. This action will create your project.
Let's configurate the pom.xml file, there you will put all project's dependencies.
- Lombok
- H2
- Test
- Web
- Data JPA
- Thymeleaf
First, we have to set the parent artifact. This parent artifact will define the version of the other dependencies.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.6.RELEASE</version>
<relativePath />
</parent>
Then, put the rest of the dependencies.
<dependencies>
<!-- Framework - Lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<!-- Database - H2 -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<!-- Spring Boot - Test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- Spring Boot - Web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<scope>provided</scope>
</dependency>
<!-- Spring Boot - Data JPA -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<scope>provided</scope>
</dependency>
<!-- Thymeleaf -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
</dependencies>
You can find the complete file at my github
The next step is to create a new class to run the application.
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class, args);
//Spring Boot (Building a web application - Running) - Part 2
}
}
That's it.
Just run the application and you will see it working.
Checkout the full code on my github
Leave Spring Boot (Building a web application - Running) - Part 2 to:
Read more #java posts
Best Posts From Namom Alencar
We have not curated any of namom's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From Namom Alencar
- Spring Boot (Introduction for Unit Tests) - Part 5
- Spring Boot (JPA Extended: Master-Detail) - Part 4
- Spring Boot (Building a web application - JPA integration) - Part 3
- Spring Boot (Building a web application - Running) - Part 2
- Spring Boot (Introduction) - Part 1 - Building a simple application
- Best way to concat String – JAVA
- Wakanda Forever
- Black Panther Lives