一、背景
随着项目的长期运行和迭代,积累的功能日益繁多,但并非所有功能都能得到用户的频繁使用或实际上根本无人问津。
为了提高系统性能和代码质量,我们往往需要对那些不常用的功能进行下线处理。
那么,该下线哪些功能呢?
此时,我们就需要对接口的调用情况进行统计和分析了!
二、实战
以下内容为主要代码,完整代码请参考:https://gitee.com/regexpei/daily-learning-test
以下使用 自定义注解 + AOP 的方式,对接口调用进行记录。
1. 创建项目,添加依赖
<dependencies>
<!-- 提供自动配置、日志、YAML等核心功能 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<!-- 提供面向切面编程支持 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<!-- 用于构建Web,包括RESTful和基于Servlet的Web应用,包含了Spring MVC、Tomcat等 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- 通过注解减少样板代码的Java库,自动生成getter、setter等方法 -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<!-- Swagger的注解库,允许开发者为API添加文档和元数据 -->
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.6.2</version>
</dependency>
<!-- 用于Java对象的JSON序列化/反序列化的库,Fastjson的继任者 -->
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
<version>2.0.41</version>
</dependency>
<!-- 为Spring Boot应用提供了测试所需的依赖项,包括JUnit等,但仅限于测试阶段 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<!-- 排除已包含的SLF4J API版本,避免版本冲突 -->
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Java工具包,提供了许多实用的工具类和方法 -->
<dependen
SpringBoot中基于AOP的接口调用统计与不常用功能下线策略

最低0.47元/天 解锁文章
4405

被折叠的 条评论
为什么被折叠?



