Back-end: Spring Boot, Spring MVC, Spring Web, Spring Data JPA、Spring Security, Hibernate, Spring Boot Actuator
- How to Start: Use the Spring Boot Maven plugin (
mvn spring-boot:run) to run the application. It will be accessible at http://localhost:8080.- Recommended Java version: 17.0.7
- Recommended Maven version: 3.6.3
- Recommended OS: linux
- How to Check the Data in the Database: Access H2-Console to view the data.
- Login:
- Nothing can be done before logging in
- Login Roles:
- Admin: Can check all the members
- User: Can't check all the members
- Get Daily Quote:
- Show the quote of the day in random
- Users can leave notes and save them
- Get My Quotes:
- Show the quotes the user has previously saved
- Users can delete their saved quotes
- Check All Members: Only accessible to Admin
- Feature: Defines allowed request origins, methods, and destinations to prevent unexpected resource leakage.
- Tech: Initialize a
CorsFilterto define the allowed request specifications.
- Feature: Specifies JSON as the format for data transmission between the client and the server, eliminating the need for manual data format conversion during coding.
- Tech:
- In the frontend AJAX, set contentType:
application/json; charset=utf-8to inform the backend that the data format being sent is JSON. - In the backend Controller, set
@RequestMapping(produces = "application/json; charset=utf-8")to check the returned data is in JSON format.
- In the frontend AJAX, set contentType:
- Feature: The framework automatically generates SQL statements, relieving developers from writing and maintaining them manually.
- Tech: Hibernate (ORM) automatically converts between objects and database records.
- Feature: The purpose of the APIs aligns with the HTTP methods, making the overall meaning clear and understandable.
- Tech: Spring Web
- Explanation:
- GET: Retrieve a resource. Read-only operation without modifying data.
- POST: Create a new resource. Usually includes a request body with the necessary data for the new resource.
- PUT: Update an existing resource. Usually includes a request body with the updated information for the resource.
- PATCH: Update a portion of an existing resource. The request body only needs to contain the information to be changed.
- Feature: Simulate user operations to ensure the integrity of the functionality.
- Tech: Use H2 to ensure a clean and independent environment for testing.
- Feature:
- Use JWT to determine user identity and maintain a certain login status after logging in for a period of time.
- Use Spring Security to enforce user authorization for the API.
- Tech:
- JWT
- Spring Security:
PasswordEncoderSecurityConfigurerAdapter
- Feature: Validate the code to ensure that the functionality meets expectations and facilitate easier execution of future refactoring.
- Tech:
- jMockit for mocking dependencies and focusing on verifying core logic.
- Object Mother Pattern to create test data.
- Feature: Periodically send requests to check the system's operational status.
- Tech: Spring Boot Actuator
- Feature: Store frequently accessed data to reduce the number of database accesses and improve performance.
- Tech:
CacheManager,@Cacheable