Original Tutorial: Build a Full Stack Application Using Spring Boot and Thymeleaf on educative.io
Tech stacks: Spring Boot, Thymeleaf, Bootstrap, jQuery
Beyond the designated tasks, I've made some improvements in this project. Specifically, in the provided students.html
template, the delete
button did not work, so I fixed this bug.
- Task 1: Resource Allocation (src/main/resources/application.properties)
- Task 2: Adding data from a file (src/main/resources/application.properties)
- Task 3: Create Entities (src/main/java/com/example/thymeleaf/entity/Student.java)
- Task 4: Create Data Transfer Objects (src/main/java/com/example/thymeleaf/dto/CreateStudentDTO.java)
- Task 5: Implement Student Repository (src/main/java/com/example/thymeleaf/repository/StudentRepository.java)
- Task 6: Implement the Index Controller (src/main/java/com/example/thymeleaf/controller/IndexController.java)
- Task 7: Create Get Request Handle (src/main/java/com/example/thymeleaf/controller/StudentController.java)
- Task 8: Create Post Mapping (src/main/java/com/example/thymeleaf/controller/StudentController.java)
- Task 9: Implement Delete Student (src/main/java/com/example/thymeleaf/controller/StudentController.java)
- Task 10: Student Template (src/main/resources/templates/students.html)
- Task 11: Build the Spring Boot Application
- Task 12: Run the Spring Boot Application
This project uses H2 in-memory database as we do not need to persist the data. By default, it is volatile and all stored data loss when we restart the application.
Make sure you are inside the sprithyme
repository
cd /sprithyme
Verify the installation of Maven
mvn -v
Build your Spring Boot application
mvn clean install
Now that your application is compiled, let’s run it with the following command
mvn spring-boot:run
Access the application at http://localhost:8080/students
Access the H2 database after you've run the application at http://localhost:8080/h2-console. Make sure to check the application.properties
file for correct information asked when accessing the in-memory database.
Terminate your current terminal to stop the application as well as free up the current port.
For further reference, please consider the following sections:
- Official Apache Maven documentation
- Spring Boot Maven Plugin Reference Guide
- Create an OCI image
- Spring Web
- Thymeleaf
- Spring Boot DevTools
The following guides illustrate how to use some features concretely: