English | 简体中文
Quickly build web applications, integrate Knife4j interface documentation, customize error codes and global exception handlers, all in EasyWeb.
To get started with EasyWeb, you can follow these simple steps:
-
Create a SpringBoot project without adding
Web dependencies
. -
Add the dependency coordinates:
<dependency> <groupId>icu.qimuu</groupId> <artifactId>EasyWeb</artifactId> <version>0.0.6</version> </dependency>
-
Configuration information:
-
💥 Starting from
0.0.6
in the new version, you can use the Knife4j interface documentation, custom error codes, and global exception handlers without any configuration, and you will not feel the presence of EasyWeb -
Of course, you can also configure some
personalized
configurations that you need. The configurations are as follows:
knife4j: config: name: Author email: xxx version: API version title: API document description: API document description scan-path: com.qimuu.demo.controller spring: profiles: active: dev mvc: path match: matching-strategy: ant_path_matcher
When using, annotations such as
@RestController
or@Controller
need to be added to the control layer class -
-
Sample code
@GetMapping("/getPoisonousChickenSoupNotSetKey") public BaseResponse<PoisonousChickenSoupResponse> getPoisonousChickenSoupNotSetKey() { PoisonousChickenSoupResponse poisonousChickenSoup = null; try { poisonousChickenSoup = apiService.getPoisonousChickenSoup(); } catch (BusinessException e) { throw new BusinessException(e.getCode(), e.getMessage()); } return ResultUtils.success(poisonousChickenSoup); }
-
Response Example:
{ "code": 0, "data": { "text": "The three major human illusions a phone rings, someone knocks at the door, and they like me." }, "message": "ok" }
If you do not want to use the Knife4j interface documentation, simply configure as follows to close the knife4j interface
knife4j:
enable: true
production: true
knife4j:
# Enable enhanced configuration
enable: true
basic:
enable: true
# Set your own Basic authentication user name
username: root
# Set your own Basic authentication password
password: 1234
-
By implementing the
Error interface
, you can define your own team’s error handling specifications!Example:
public enum ErrorCode implements Error { /** * Status code */ private final int code; /** * error message */ private final String message; /** * success */ SUCCESS(0, "ok"), /** * Request parameter error */ PARAMS_ERROR(40000, "请求参数错误"); @Override public int getCode() { return code; } @Override public String getMessage() { return message; } }
Compared with the traditional way of creating web projects, there is no need to integrate interface documents, and it has rich error codes and flexible global exception handlers.
-
Traditional way of creating web projects:
-
Create a new project.
-
Write a global exception handler.
-
Integrate the interface document.
-
Customize error codes.
-
Customize the common return class.
-
Write business code.
-
-
Use EasyWeb:
- Create a new project.
- Add EasyWeb coordinates.
- Configure scanning paths and scanning policies.
- Write business code.
EasyWeb provides a variety of features to make your web development process easier and more efficient. Some key features include:
- Quick and easy web application construction.
- Simple and intuitive API.
- Flexibility to customize your web application.
- And more!
If you have any questions or suggestions about EasyWeb, please feel free to contact us at any time: 📩 Email: [email protected] .
If you have any questions or suggestions about EasyWeb, please feel free to contact us.
Thank you for using EasyWeb! 😊