Posts

Spring Boot + OpenCSV Export Data to CSV Example

Image
Hello everyone, today we will learn how to export and download the data as a CSV file in a Spring Boot project. CSV stands for Comma-Separated-Values and it's a common format for doing a bulk data transfer between systems. For creating and parsing CSV files, we will use OpenCSV 3rd-party library. A little bit of Background Spring Boot Spring Boot makes it easy to create stand-alone, production-grade Spring-based Applications that you can "just run".  More Info -  https://spring.io/projects/spring-boot OpenCSV OpenCSV is an easy-to-use CSV (comma-separated values) parser library for Java. It was developed because all the CSV parsers at the time didn’t have commercial-friendly licenses. Java 8 is currently the minimum supported version.   More Info -  http://opencsv.sourceforge.net/ Technologies used   Java 17 Spring Boot 2.7.0 OpenCSV 5.6 Spring Data JPA H2DB Maven Project directory Maven [pom.xml] A Project Object Model or POM is the fundamental unit of work in Maven. It

Spring Boot + Jersey + Spring Data JPA Build REST CRUD APIs Example

Image
Hello everyone, today  we will learn how to develop CRUD REST APIs using the integration of Jersey with Spring boot, JPA/Hibernate, and H2DB as a database. The spring-boot-starter-jersey is a starter for building RESTful web applications using JAX-RS and Jersey. It is an alternative to spring-boot-starter-web. Jersey RESTful Web Services framework is an open source, production quality, framework for developing RESTful Web Services in Java. It provides support for JAX-RS APIs and serves as a JAX-RS Reference Implementation. What we’ll build? We are developing CRUD REST APIs using the integration of Jersey with Spring boot, JPA/Hibernate, and H2DB as a database. /api/v1/employees - GET /api/v1/employees - POST /api/v1/employees/{id} - PUT /api/v1/employees/{id} - DELETE /api/v1/employees/{id} - GET Application Directory Structure 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 co

Spring Boot + JPA/Hibernate Many to Many mapping example

Image
Hello everyone, In this tutorial, we will learn how to implement many-to-many entity mapping using JPA/Hibernate with Spring Boot, Spring Data JPA, and the H2DB database. Project Structure  See the final project structure of this tutorial. 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. It contains default values for most projects. Some of the configurations that can be designated in the POM is the project dependencies, the plugins or goals that can be executed, the build profiles, and so on. Other information such as the project version, description, developers, mailing lists, and such can withal be designated. <?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"