https://github.com/yoyocraft/quickweb
Build web application template, integrate Knife4j API documentation, customize error codes, global exception handlers, global logging (implemented using AOP), common response class and Logback logging
https://github.com/yoyocraft/quickweb
java11 knife4j maven spring-boot web
Last synced: 5 months ago
JSON representation
Build web application template, integrate Knife4j API documentation, customize error codes, global exception handlers, global logging (implemented using AOP), common response class and Logback logging
- Host: GitHub
- URL: https://github.com/yoyocraft/quickweb
- Owner: yoyocraft
- License: mit
- Created: 2023-05-31T14:36:56.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-06-02T12:55:26.000Z (about 3 years ago)
- Last Synced: 2025-01-22T19:48:33.955Z (over 1 year ago)
- Topics: java11, knife4j, maven, spring-boot, web
- Language: Java
- Homepage:
- Size: 28.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
English |
็ฎไฝไธญๆ
QuickWeb
Build web application template, integrate Knife4j API documentation, customize error codes, global exception handlers, global logging (implemented using AOP), common response class and Logback logging
> QuickWeb is a web starting project based on SpringBoot that can be used as a template for new projects. It uses
> MyBatis and MyBatis Plus as the ORM framework, Druid as the data source, MySQL as the database, and Knife4j as the API
> document generator. Additionally, this project includes features such as custom business exceptions, global logging (
> implemented using AOP), global exception handling, common response class, and Logback logging.
๐Technology Stack
- java 11
- Spring Boot 2.7.11: A fast development framework that simplifies the process of setting up a Spring application.
- MyBatis & MyBatis Plus: A persistence framework that provides many convenient interfaces for CRUD operations.
- Druid: Alibaba's open-source database connection pool and monitoring component.
- MySQL: Open-source relational database.
- Knife4j: An API document generation tool based on Swagger.
๐ชFeatures
- Custom business exceptions: throw custom exceptions when business errors occur and catch and handle them through
global exception handlers.
- Global logging (implemented using AOP): Intercept all Controller methods through AOP and record relevant information
about requests and responses before and after method execution.
- Global exception handling: Capture global exceptions and handle them uniformly, returning friendly error messages.
- Common response class: encapsulates some common response status codes and messages for quick construction of response
bodies.
- Knife4j API documentation generation: Generates API documentation through annotations and configuration, making it
easy for developers to view and debug interfaces.
๐Quick Start
1. Install MySQL and create a database.
2. Modify the database connection information in `application-dev.yml`.
3. Run the main class `MainApplication`.
4. Visit `http://localhost:8080/api/doc.html` to view the API documentation.
5. Integrate into your own project
1. Modify the project name in `logback.xml` to your own
2. Modify the database configuration
3. Modify knife4j configuration (see [๐งConfiguration Item Description](#๐งconfiguration-item-description))
4. Modify the port number and `context-path` as needed
๐Configuration File Description
- `application.yml`: Application configuration file, including database connection information, log configuration, etc.
- `application-dev.yml`: Development application configuration file, including database connection information, log
configuration, etc.
- `application-prod.yml`: Online application configuration file, including database connection information, log
configuration, etc.
- `logback.xml`: Logback configuration file, including parameters for logging file records, etc.
๐งConfiguration Item Description
Complete configuration items:
```yaml
knife4j:
config:
# Core configuration
base-package: com.juzi.quickweb.controller
# Secondary configuration
title: QuickWeb API Document
description: Helps to quickly build web applications
version: 0.0.1
contact-name: codejuzi
contact-email: d1741530592@163.com
contact-url: codejuzi.icu
license: MIT
license-url: https://mit-license.org/
```
๐งพDirectory Structure Description
```
.
โโโ Dockerfile
โโโ README.md
โโโ logs
โ โโโ myapp.log
โโโ pom.xml
โโโ src
โโโ main
โ โโโ java
โ โ โโโ com
โ โ โโโ juzi
โ โ โโโ quickweb
โ โ โโโ MainApplication.java
โ โ โโโ aspect
โ โ โ โโโ LogAspect.java # Controller layer logging AOP
โ โ โโโ common
โ โ โ โโโ BaseResponse.java # Common response class
โ โ โ โโโ StatusCode.java # Custom status codes
โ โ โโโ configuration
โ โ โ โโโ CorsConfig.java # Global cross-domain configuration
โ โ โ โโโ DataSourceConfig.java # Data source configuration
โ โ โ โโโ Knife4jConfig.java
โ โ โ โโโ MyBatisPlusConfig.java
โ โ โโโ controller
โ โ โโโ exception
โ โ โ โโโ BusinessException.java # Custom business exceptions
โ โ โ โโโ GlobalExceptionHandler.java # Global exception handler
โ โ โโโ util
โ โ โโโ ResultUtils.java
โ โ โโโ ThrowUtils.java
โ โโโ resources
โ โโโ application-dev.yml
โ โโโ application-prod.yml
โ โโโ application.yml
โ โโโ logback.xml
โโโ test
โโโ java
โโโ com
โโโ juzi
โโโ quickweb
โโโ MainApplicationTest.java
```
ยฉ๏ธCopyright
Open-sourced under the MIT License.