- Creating diagram to understand the whole picture of the project in my mind: http://draw.io.
- Choosing to create this project with Spring initializr to make it fast and simple as possible: https://start.spring.io.
Specifically:
WEB
- Spring Web (Build web, including ERSTful, applications using Spring MVC, Uses Apache Tomcat as the default embedded container).
SQL
- Spring Data JPA (Persist data in SQL with Java Persistence API using Spring Data and Hybernate).
- PostgreSQL Driver A JDBC and R2DBC driver that allows Java programs to connect to a PostgreSQL database using standard, database independent Java code.
- Commenting JPA dependency to start program without errors
@SpringBootApplication
@RestController public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
@GetMapping
public List<String> hello() {
return List.of("Hello", "Spring");
}
}
- Creating package and class called Student
- Creating list of Students in main class
- Organize code for better understanding and overview
- Adding Business (service) layer. Anterior design pattern.
- Split things into layers. API layer talk with Service layer & vice versa
- Configurating connection to database
- Creating a Postgres database called student
- Preparing project to connect it with Database
- Connecting project with Database
- Implementing the data access layer
- Filling our repository with students
- Calculate age based on the date of birth