Posts

Showing posts with the label Spring Boot Examples

Java Record as DTO in Spring Boot Application

Image
In this section, we will show how we used Java Record as DTO in the Spring Boot application. The  GitHub repository link is provided at the end of this tutorial. You can download the source code. From Java 14 onwards, the record is a special type of class declaration aimed at reducing the boilerplate code. Technologies used :  Spring Boot 2.6.3 Spring  Data JPA  Java 17  H2 DB Maven 3+  Let's do it, Final Project Directory Maven[pom.xml]   A Project Object Model or POM is the fundamental unit of work in Maven. It is an XML file that contains information about the project and configuration details utilized by Maven to build the project.  <?xml version = "1.0" encoding = "UTF-8" ?> <project xmlns = "http://maven.apache.org/POM/4.0.0" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation = "http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" > <modelVersion&g

Spring Data JDBC, PostgreSQL, CRUD Example

Image
  Hello everyone, In this article, we will learn how to develop a  REST-style web service with Spring Boot, Spring Data JDBC, and PostgreSQL Database. GitHub repository link is provided at the end of this tutorial. You can download the source code. What's new in this example?  From Java 14 onwards,  the record  is a special type of class declaration aimed at reducing the boilerplate code. For more info  click here From Java 10 onwards,  the var  keyword allows local variable type inference, which means the type for the local variable will be inferred by the compiler, so we don't need to declare that. For more info  click here Technologies used :  Spring Boot 2.6.3 Spring  Data JDBC  Java 17  PostgreSQL Maven 3+  These are APIs that Spring backend App will export:   GET all User's        :     /api/v1/users             : get  GET User by ID     :     /api/v1/users/{id}       : get CREATE User        :     /api/v1/users             : post UPDATE User        :     /api/v1/user