Getting Started With Spring Boot With Postgres

Beginners Guide to Using Postgres with Spring Boot

Suraj Mishra
Javarevisited

--

Originally Published in https://asyncq.com/

Introduction

  • The goal of this article is to set up a Postgres database with sample data and then use Spring boot to connect with the database and serve data to the end user as the rest endpoint.
  • Note that this article is beginner-friendly. All the codes have been made available on GitHub
  • In future articles, I will use this setup to demonstrate some of the advanced databases, and JPA concepts ( associations, partitioning, sharding, transactions, etc) using the help of setup performed in this article.

Install Postgres

Install Postgres Database

  • I have a mac environment so my commands are most suitable for mac. i believe there are equivalent tools to install on the respective environment like windows and Linux.
#install database
brew install postgresql

# start database
brew services start postgresql

Configure

  • Once we started the service, we can log in to the default postgres database

--

--