Developing your first Spring Boot application or starting from scratch. This blog is a great boilerplate or starter template for your spring boot project. Learn how to set up your project using the standard folder structure and files. You will learn how to setup your Spring Boot project using standard settings, folder structure. Learn how to create project using Initialzr and add dependencies for your project. Also learn what are the necessary dependencies for starting your project.
In this blog we will setup a Java Spring Boot Project using following:
- Maven
- Spring Boot 2.7.2
- Java 17
- Dependencies – Spring Web, Spring Security, Spring Data JPA, Thymeleaf, Spring Boot DevTools, PostgreSQL Driver
Note: You can remove and add dependencies as per your requirements.
Download Project using Spring Initializr
Generate your spring boot project and add dependencies using Spring Initialzr. Go to https://start.spring.io/ and select the requirements as per your project. I have attached the bellow image for your reference.

You need to add dependencies by clicking “ADD DEPENDENCIES” button. Once you click on Generate button, you project will be downloaded with all required files and folders. You can access my setup using the following link.
Setup Initial Project using Spring Boot
Once your project is downloaded, open it in your favourite IDE. I would recommend IntelliJ IDEA. Once you have loaded the project in your IDE, add the following settings in your application.properties
file
#-------------------- server properties --------------- server.port=8080 server.error.include-message=always #--------------------- Logging ------------------ logging.level.org.hibernate.SQL=DEBUG logging.level.org.hibernate.type=TRACE logging.level.org.springframework.web=DEBUG logging.level.org.hibernate=ERROR #--------------------- DB Connection ------------------ spring.datasource.url=jdbc:postgresql://localhost:5432/myproject spring.datasource.username=myuser spring.datasource.password=password #--------------------JPA-ORM Properties----------------- spring.jpa.show-sql=true spring.jpa.hibernate.ddl-auto=update spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect spring.jpa.properties.hibernate.format_sql=true
If you are using PostgreSQL in your project you need to first create the database. Use bellow commands to create
sudo -u postgres psql CREATE DATABASE myproject; CREATE USER myuser WITH PASSWORD 'password'; ALTER ROLE myuser SET client_encoding TO 'utf8'; ALTER ROLE myuser SET default_transaction_isolation TO 'read committed'; ALTER ROLE myuser SET timezone TO 'UTC'; GRANT ALL PRIVILEGES ON DATABASE myproject TO myuser;
Once everything is done, go to your project main file, where public static void main
resides and run the project. If your project runs successfully, go to localhost:8080 .