This repository contains a Java Spring Boot project built with Maven. It is intended to be used as a reference only and should not be copied in any form. The project includes various components and functionality related to [insert specific details of project here]. Please feel free to browse the code and use it as a resource for learning, but do not use it for any other purposes. Thank you for respecting the terms of this repository.
- Spring Boot
- Spring Data JPA (Hibernate)
- Thyemeleaf template engine
- Bootstrap 5
- H2 Database (Store in file)
- Maven (for dependency management)
- Java 17
- IntelliJ IDEA for development
- Git and GitHub (for version control)
- GitHub Desktop (for pushing to GitHub)
- Heroku (for deployment)
- Postman (for testing)
- Go to application.properties and config your port and database connection.
- Insert new row in database via data.sql in resources folder.
#Thymeleaf To use ThymeLeaf Engine => remember add this before every html file
<!DOCTYPE html>
<html lang="vi"
xmlns:th="http://www.thymeleaf.org">
##Codeing Convention Follow the structure of this project
Change/Modify header bar ? => Go to resources/templates/fragments/header.html
Change/Modify footer bar ? => Go to resources/templates/fragments/footer.html
POST method? -> @PostMapping("/url") in controller, and add form action with method="POST" and th:action="@{/url}"
FAQ:
- How to add new page ?
- Create new html file in resources/templates
- Add new link in header.html
- Add new Mapping in controller
- What "th:..." in html file mean ?
- th:text => display text
- th:href => link to another page
- th:src => display image
- th:each => loop
- Many and many more, you can find it in Thymeleaf document or Stackoverflow
- I dont want to use H2 database, how to change to MySQL ?
- Go to application.properties and change to your database connection
- Go to pom.xml and remove H2 dependency and add MySQL dependency
- Go to data.sql and remove all data
- Run project and it will create new table in your database
- Insert new data via Postman or other tools
- Done
- I dont want to use Thymeleaf, how to change to JSP ?
- Change pom.xml
- Change application.properties
- Change controller
- Change html file to JSP file
- Change all th: to jsp:tag
- Change all ${} to <%= %>
- Change all @{} to <%= %>
- So hard to understand, can you give me an help me code ?
- NO
- NO
- NO
- Repeating something three times can help to emphasize its importance
--------------The most important thing----------------
- Open project with IntelliJ IDEA
- Run project
- Open browser and go to localhost:8081
- Enjoy it
- Open terminal
- Go to project folder
- Run command: mvn spring-boot:run (after install maven)
- Open browser and go to localhost:8081
- Enjoy it
- Open project with Spring Tools 4 for Visual Studio Code or Eclipse
- Run project (Do it yourself)
- Open browser and go to localhost:8081
- Enjoy it
- Open terminal
- Go to project folder
- Run command: docker build -t demo .
- Run command: docker run -p 8081:8081 demo
- Open browser and go to localhost:8081
- Enjoy it
- Open terminal
- Press
./mvnw clean package -DskipTests
to build project and get jar file. - get file .jar in target folder and copy to folder docker have docker-compose.yml
- Run command:
docker-compose up -d
- Open browser and go to localhost:8081