Billing System using Spring Boot Project. Setup entity mapping and Lombok configuration-03

Billing System using Spring Boot Project. Setup entity mapping and Lombok configuration-03

Hello friends, I have come up with Project setup Spring Boot. I am using the following version of Spring Boot.
<relativePath/> <!– lookup parent from repository –>

Following is the Project structure

Billing System using spring boot
Billing System using spring boot


The Parent Package is com.itgarden and the followings are subpackage.
controller = This package contains all Rest Service Controller class.
service = This package contains all Service class.
repository = This package contains all repository class.
entity = This package contains all entity classes which mapped with DB Table.
util = This package contains utility class like Date methods other common utility methods.
Resource Folder
In the resource folder, I am keeping only and appication.yml file. I am using only the application.yml file for application configuration.

The following info I have configured in the Application yml file.
Our application runs under 9091 port
I have given the following properties in the JPA properties,
show-sql: true
This property enables the SQL query in the log.
ddl-auto: update — Whenever change anything in the Java Entity class, the same get updated respective Database Table.
Below is the DB connection configuration. Please change your DB info accordingly.
url: jdbc:mysql://localhost:3306/billing
username: billing
password: billing123$$
driver-class-name: com.mysql.cj.jdbc.Driver

I have basic logging information but I will change that to later with proper logger configuration. I will come with a separate story for that.

Currently, this is the Project Structure and configuration for our billing System. I will add more configuration in our Project based on our needs.
When you look at the POM file I have given the following artifact, one is “mapstruct” and another one is “lombok”. Mapstruct for mapping entity object to DTO object. I will explain more about this later. As of now, I have not done anything using mapstruct.
Lombok is a very useful library. This library takes care of setter/getter generation and constructor. We don’t have to write manually getter/setter, Constructor.

In the entity mapping, I have given @Data Annotation which is part of the Lombok library. This annotation generates the getter/setter method at runtime.
All entity mapping extends from BaseObject class

public class Customer extends BaseObject {

This BaseObject class Annotated with @MappedSuperclass. The reason I am using this, I want to map this class attributes to part of all Child class entity attributes to respective DB Table. This class contains dateCreated, dateModified, and deleted attributes. These attributes are common fields for all the table so, I want to move these properties in the parent class and I am resuing those properties in all child classes. In order to work this entity mapping with all child classes, we need to use @MappedSuperclass Annotation.

After adding the Lombok artifact in your IDE, It never works in your IDE. We have to install the Lombok plugin for Intellij and we have to add some configuration for eclipse and STS IDE. Please go through the following story to complete the Lombok setup.

Lombok configuration in Eclipse,IntelliJ and STS IDE

Billing System-related YouTube video links are available here
Billing System using spring Boot YouTube Playlist link

Close Menu