使用 Java 21 和 Spring Boot 3 构建的 RealWorld 后端 API
使用 Java 21 和 Spring Boot 3 构建的 RealWorld 后端 API
Java 21 + Spring Boot 3 codebase containing real-world examples (CRUD, authentication, advanced patterns, etc.) that adheres to the RealWorld specification and API.
This codebase demonstrates a fully-fledged fullstack application built with Java 21 + Spring Boot 3, including CRUD operations, authentication, routing, pagination, and more.
If you want to see the API documentation related to this, please refer to https://1chz.github.io/realworld-java21-springboot3
For more information on how this works with other frontend/backends, visit the RealWorld repository.
While implementing this application, the following considerations were made:
The RealWorld project aims to create mini-blog applications with identical specifications using various technology stacks, allowing for easy comparison.
This application provides the following key features:
The project is implemented using Java 21 and Spring Boot 3, leveraging technologies such as Spring MVC, Spring Data JPA, and Spring Security. It uses H2 DB (in-memory, MySQL mode) as the database and JUnit 5 for testing.
To run the project, ensure that JDK (or JRE) 21 is installed. Then, execute the following command in the project root directory:
./gradlew realworld:bootRunAccess the application at http://localhost:8080 in your browser.
The project is organized into library and server modules:
Library Modules (located in the module directory):
core: Contains core logic, domain models, service interfaces, and exception handling.persistence: Contains persistence layer logic, repositories, and entities.Server Modules (located in the server directory):
api: Contains the API layer logic, controllers, DTOs, and exception handling.All modules depend on the core module, following the Dependency Inversion Principle (DIP).
Note: Data types were carefully considered, but column sizes were not a primary focus.
Many developers using JPA tend to use Long as the ID type. However, consider whether your table will ever require storing (2^{63}) records.
Note: Ensure JDK 21 is installed.
Note: If you encounter a permission denied error when running Gradle tasks, run
chmod +x gradlewto grant execution permission.
API documentation is available at https://1chz.github.io/realworld-java21-springboot3, generated using ReDoc in HTML format.
You can also import the api-docs/openapi.yaml file into Postman or Swagger UI to test the API.
./gradlew realworld:bootRunNote: The code style task runs automatically during the build. If the code style does not match, the build will fail.
./gradlew spotlessApply./gradlew test./gradlew build暂无开放 Issues,或尚未同步最近议题。