PFB the link reference for basic spring boot projects and concepts,
1)Open 'Spring Tool Suite' tool
2)Create 'Spring Starter Project'
For Reference:
For Reference:
3)Project structure looks like
4)Open 'application properties' file and add the below content,
It will determine the database configurations.
4.2)spring.jpa.show-sql=true
It helps to print database queries in console. Show or not log for each sql query
4.3)spring.jpa.hibernate.ddl-auto=update
On every time (Project start or restart) it will check with database and update the table and it's columns. Hibernate ddl auto (create, create-drop, update).
4.4)spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect
SQL dialect makes Hibernate generate better SQL for the concern database.
5)Create Controller and Model classes
5.1)DemoController.java
5.1.1)@RestController - makes this class as Rest API based controller class
5.1.2)@RequestMapping - helps to communicate the API calls
5.2)BaseEntity.java
5.2.1)BaseEntity:
It is an abstract class and it has the generic data which has common for all tables. Ex: Created by, created data, modified by and modified data.
5.2.2)MappedSuperclass annotation:
It defines the parent classes and tells parent class can't be entities
5.2.3)Id annotation:
It helps to create primary key for table
5.2.4)GeneratedValue annotation:
IT helps to generate sequences for primary key
5.2.5)Column annotation:
It creates the column in table
5.3)DemoModel.java
5.3.1)DemoModel:
It is entity class and it extends the BasEntity abstract class to get common column.
5.3.2)Entity annotation:
It defines the class as entity class
5.3.3)Table annotation:
It helps to create table in database
5.3.4)Getter and Setter annotations:
It take care of the getter and setter declaration and tasks
5.3.5)Column annotation:
It creates the column in table
Use the below link to download the source code,
Previous session: Click to know - Spring Boot Code Flow
Next session: Click to know - Crud spring boot project
Context page: Click here
Home page: Click here
Thanks, I hope you enjoyed this session !!!.
-Somasundar Kanakaraj