diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..410be32
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,44 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+.mvn/
+test/
+test/*
+# But not empty folders
+!*/
+
+
+
+
+
diff --git a/README.en.md b/README.en.md
deleted file mode 100644
index e9f6b80..0000000
--- a/README.en.md
+++ /dev/null
@@ -1,36 +0,0 @@
-# springboot-template
-
-#### Description
-快速搭建spingboot项目让你上手就开始写业务,帮你依赖了目前国内比较火的框架、数据源、yml通用配置:MySQL、Redis、mybatis-plus...
-
-#### Software Architecture
-Software architecture description
-
-#### Installation
-
-1. xxxx
-2. xxxx
-3. xxxx
-
-#### Instructions
-
-1. xxxx
-2. xxxx
-3. xxxx
-
-#### Contribution
-
-1. Fork the repository
-2. Create Feat_xxx branch
-3. Commit your code
-4. Create Pull Request
-
-
-#### Gitee Feature
-
-1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
-2. Gitee blog [blog.gitee.com](https://blog.gitee.com)
-3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
-4. The most valuable open source project [GVP](https://gitee.com/gvp)
-5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
-6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
diff --git a/README.md b/README.md
index f045032..7e4db18 100644
--- a/README.md
+++ b/README.md
@@ -1,37 +1,103 @@
-# springboot-template
+# 这个项目是干什么的
+- 提供基础框架,让你进行快速开发。对于每次新建项目时,各种的建包、基础的日志监控、以及提供标准的日志格式文件等等...通用的功能太耽误我们的时间于是,于是萌生这个想法将这些东西抽离出来,使用的时候将他拉取下来改文件夹名字,就搭建好了基础框架。就像是代码生成器
+- 记得我学习spring-boot的时候,有一句话到现在仍记得`约定大于配置`,所以我希望使用本项目的遵从我的约定,当然你也可以进行改动
+## 目前已搭建好
-#### 介绍
-快速搭建spingboot项目让你上手就开始写业务,帮你依赖了目前国内比较火的框架、数据源、yml通用配置:MySQL、Redis、mybatis-plus...
+1. API请求日志监控
+2. 全局异常日志监控
+3. 提供日志文件格式
+4. 全局响应类
+5. Redis序列化
+6. swagger通用配置
+7. knife4j框架集成
+8. 跨域配置
+9. 通用的yml配置
-#### 软件架构
-软件架构说明
+## 目前已集成的依赖
+### spring-boot帮我们做版本依赖
-#### 安装教程
+1. `spring-boot-starter-web`:servlet
+2. `spring-boot-starter-aop`:aop编程
+3. `spring-boot-starter-test`:模块测试
+4. `spring-boot-starter-validation`:参数校验
+5. `spring-boot-starter-data-redis`:redis集成
+6. `mysql-connector-j`:MySQL驱动
+7. `spring-boot-starter-jdbc`:基于MySQL驱动提供jdbc简单编程
+8. `lombok`:get/set方法
-1. xxxx
-2. xxxx
-3. xxxx
+### 需要去官网/仓库去看版本信息
-#### 使用说明
+1. `hutool-all`:java语法糖
+2. `knife4j-openapi3-jakarta-spring-boot-starter`:基于swagger的接口测试框架
+3. `mybatis-plus-boot-starter`:用代码写SQL
+4. `pagehelper-spring-boot-starter`:分页工具
-1. xxxx
-2. xxxx
-3. xxxx
+### 测试说明
-#### 参与贡献
+1. 在`com.template.controller`包下有三个测试文件测试项目集成的依赖、功能能否使用。当然这样存放文件是不标准,测试结束没问题可以删除,注意exception包的文件不可以删除可以修改
+ - Redis集成测试
+ - MySQL集成测试
+ - 日志监控测试
+2. 测试接口框架:查看`localhost:8080/doc.html`
+3. 在`application-dev.yml`文件中
+ - redis:需要连接自己的
+ - mysql:需要来连接自己数据库,**script/init.sql**提供了sql脚本请务必使用,否则关于MySQL的测试可能失败
-1. Fork 本仓库
-2. 新建 Feat_xxx 分支
-3. 提交代码
-4. 新建 Pull Request
+## 启动类说明
+1. 项目中能使用并带有`Enable`的注解都已经加上
-#### 特技
-1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
-2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com)
-3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目
-4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
-5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
-6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
+
+
+## 包介绍
+- **文件存放请按照图中来**
+```text
+main/
+├── java
+│ └── com
+│ └── template
+│ ├── annotation 自定义注解包
+│ ├── Application.java 启动类
+│ ├── config 配置包
+│ ├── controller controller层
+│ │ ├── exception
+│ │ │ └── ExceptionController.java 全局异常类
+│ │ ├── TestController.java 测试类
+│ │ ├── TestUseEntity.java 测试类
+│ │ └── TestUserMapper.java 测试类
+│ ├── core 核心包,这里面都是增加的功能一般不用动这个包,也不要把文件创建在这里
+│ │ ├── log
+│ │ │ ├── BaseLog.java
+│ │ │ └── MonitorAPI.java
+│ │ ├── redis
+│ │ │ └── config
+│ │ │ └── RedisConfig.java
+│ │ ├── resp
+│ │ │ ├── Resp.java 全局响应类
+│ │ │ └── R.java 自定义响应需要实现这个接口
+│ │ ├── swagger
+│ │ │ └── SwaggerConfig.java
+│ │ └── web
+│ │ └── SpringMvcWebConfig.java 跨域配置
+│ ├── dictionary 字典包
+│ ├── domain 领域包,可以自定义以下包是推荐的
+│ │ ├── dto
+│ │ ├── service
+│ │ └── vo
+│ ├── entities ActiveRecord包,也就是实体类包
+│ ├── exception 自定义异常包
+│ ├── filter 过滤器包
+│ ├── interceptor 拦截器包
+│ ├── mapper 相当于mapper包但是这样命名更加规范
+│ └── utils 工具包
+└── resources
+ ├── application-config.yml
+ ├── application-dev.yml
+ ├── application.yml
+ ├── logback.xml 日志格式文件
+ ├── mapper mybatis文件
+ └── script
+ └── init.sql sql脚本
+```
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..4e3be46
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,118 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 3.1.3
+
+
+
+ com.xxl
+ springboot-template
+ version:3.1.3
+
+
+ springboot-template
+ spring boot项目模板
+
+
+
+ 17
+ UTF-8
+ UTF-8
+ 17
+ 17
+
+ 4.2.0
+ 3.5.3.1
+ 1.4.6
+ 5.8.20
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+ org.springframework.boot
+ spring-boot-starter-jdbc
+
+
+
+ com.mysql
+ mysql-connector-j
+ runtime
+
+
+
+ com.baomidou
+ mybatis-plus-boot-starter
+ ${com.baomidou.version}
+
+
+
+ org.springframework.boot
+ spring-boot-starter-aop
+
+
+
+ org.springframework.boot
+ spring-boot-starter-validation
+
+
+
+ cn.hutool
+ hutool-all
+ ${cn.hutool.version}
+
+
+
+ com.github.pagehelper
+ pagehelper-spring-boot-starter
+ ${pagehelper-spring-boot-starter.version}
+
+
+
+ com.github.xiaoymin
+ knife4j-openapi3-jakarta-spring-boot-starter
+ ${com.github.xiaoymin.version}
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+ org.projectlombok
+ lombok
+
+
+
+
+
+
+
+
diff --git a/src/main/java/com/template/Application.java b/src/main/java/com/template/Application.java
new file mode 100644
index 0000000..e634f19
--- /dev/null
+++ b/src/main/java/com/template/Application.java
@@ -0,0 +1,37 @@
+package com.template;
+
+import lombok.extern.slf4j.Slf4j;
+import org.mybatis.spring.annotation.MapperScan;
+import org.mybatis.spring.annotation.MapperScans;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.EnableAspectJAutoProxy;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.stereotype.Indexed;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+/**
+ * @author: anyone
+ * @since: 2023/9/16
+ * @description: 启动类
+ */
+@EnableAspectJAutoProxy
+@EnableAsync
+@EnableScheduling
+@EnableTransactionManagement
+@Slf4j
+@Indexed
+@MapperScans({@MapperScan("com.template.mapper"),@MapperScan("com.template.controller")})
+@SpringBootApplication
+public class Application {
+
+ public static void main(String[] args) {
+ try {
+ SpringApplication.run(Application.class, args);
+ log.info("项目启动成功(ง ˙o˙)ว");
+ } catch (Exception e) {
+ log.error("启动失败:",e);
+ }
+ }
+}
diff --git a/src/main/java/com/template/controller/TestController.java b/src/main/java/com/template/controller/TestController.java
new file mode 100644
index 0000000..1a61321
--- /dev/null
+++ b/src/main/java/com/template/controller/TestController.java
@@ -0,0 +1,82 @@
+package com.template.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.template.core.resp.R;
+import com.template.core.resp.Resp;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.annotation.Resource;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * 测试项目是否可以运行
+ * @author xxl
+ * @since 2023/9/16
+ */
+@RestController
+@RequestMapping(value = "/test", produces = "application/json")
+@Slf4j
+@Tag(name = "测试API")
+public class TestController {
+ /**
+ * 测试接口
+ * @return
+ */
+ @GetMapping("/hello")
+ @Operation(summary = "测试接口")
+ public Resp hello() {
+ return R.success();
+ }
+
+ @Resource
+ RedisTemplate redisTemplate;
+ /**
+ * 测试redis
+ * @param key
+ * @return 成功返回OK
+ */
+ @GetMapping("redis")
+ @Operation(summary = "测试redis")
+ @Parameter(name = "key",description = "redis的key")
+ public Resp redis(@RequestParam("key")String key) {
+ redisTemplate.opsForValue().set("username","xxl");
+ Object o = redisTemplate.opsForValue().get(key);
+ log.info("查询:key=>{},value=>{}",key,o);
+ redisTemplate.keys("*").forEach(dto -> log.info("key=>{},value=>{}",dto,redisTemplate.opsForValue().get(dto)));
+ return R.success();
+ }
+
+ /**
+ * 测试MySQL
+ * @param id
+ * @return 成功返回OK
+ */
+ @GetMapping("mysql")
+ @Operation(summary = "测试mysql")
+ @Parameter(name = "id",description = "列id")
+ public Resp mysql(@RequestParam("id")String id) {
+ TestUseEntity user = new TestUseEntity();
+ //插入
+ user.setId("16494");
+ user.setUsername("XXL");
+ user.setPasswd("123456");
+ user.insert();
+
+ // 指定查询
+ TestUseEntity testUseEntity = user.selectById(id);
+ log.info("id:{},value:{}",id,testUseEntity.toString());
+
+ //查询所有
+ List testUseEntities = user.selectList(new LambdaQueryWrapper<>());
+ testUseEntities.forEach(dto -> log.info(dto.toString()));
+ return R.success();
+ }
+}
diff --git a/src/main/java/com/template/controller/TestUseEntity.java b/src/main/java/com/template/controller/TestUseEntity.java
new file mode 100644
index 0000000..9ec2dbe
--- /dev/null
+++ b/src/main/java/com/template/controller/TestUseEntity.java
@@ -0,0 +1,31 @@
+package com.template.controller;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * @author xxl
+ * @since 2023/9/17
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+@Accessors(chain = true)
+@TableName("test_user")
+public class TestUseEntity extends Model implements Serializable {
+ @Serial
+ private static final long serialVersionUID = -6083882932972222185L;
+ @TableId
+ private String id;
+ @TableField("username")
+ private String username;
+ @TableField("passwd")
+ private String passwd;
+}
diff --git a/src/main/java/com/template/controller/TestUserMapper.java b/src/main/java/com/template/controller/TestUserMapper.java
new file mode 100644
index 0000000..85de0a0
--- /dev/null
+++ b/src/main/java/com/template/controller/TestUserMapper.java
@@ -0,0 +1,11 @@
+package com.template.controller;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * @author xxl
+ * @since 2023/9/17
+ */
+public interface TestUserMapper extends BaseMapper {
+
+}
diff --git a/src/main/java/com/template/controller/exception/ExceptionController.java b/src/main/java/com/template/controller/exception/ExceptionController.java
new file mode 100644
index 0000000..ea9a09e
--- /dev/null
+++ b/src/main/java/com/template/controller/exception/ExceptionController.java
@@ -0,0 +1,24 @@
+package com.template.controller.exception;
+
+import com.template.core.resp.R;
+import com.template.core.resp.Resp;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.RestControllerAdvice;
+
+/**
+ * 对异常的统一返回
+ * @author xxl
+ * @since 2023/9/16
+ */
+@RestControllerAdvice
+@Slf4j
+public class ExceptionController {
+ /**
+ * 捕捉spring boot容器所有的未知异常
+ */
+ @ExceptionHandler(Exception.class)
+ public Resp> exception(Exception exception) {
+ return R.fail();
+ }
+}
diff --git a/src/main/java/com/template/core/log/BaseLog.java b/src/main/java/com/template/core/log/BaseLog.java
new file mode 100644
index 0000000..b789c31
--- /dev/null
+++ b/src/main/java/com/template/core/log/BaseLog.java
@@ -0,0 +1,73 @@
+package com.template.core.log;
+
+import cn.hutool.core.util.ObjectUtil;
+import jakarta.annotation.Resource;
+import jakarta.servlet.http.HttpServletRequest;
+import lombok.extern.slf4j.Slf4j;
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Before;
+import org.aspectj.lang.annotation.Pointcut;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.Arrays;
+
+/**
+ * 日志监控
+ * @author xxl
+ * @since 2023/9/16
+ */
+@Aspect
+@Component
+@Slf4j
+public class BaseLog {
+ @Resource
+ HttpServletRequest request;
+ @Pointcut("execution(* com.template.controller..* (..)) && !execution(* com.template.controller.exception..*(..))")
+ public void apiPointCut() {
+ }
+ @Pointcut("execution(* com.template.controller.exception..* (..))")
+ public void exceptionPointCut() {
+ }
+
+
+ private MonitorAPI monitor;
+
+ @Autowired(required = false)
+ public void setMonitor(MonitorAPI monitor) {
+ this.monitor = monitor;
+ }
+
+ /**
+ * com.template.controller包下的所有接口的aop监控
+ * @param point 切点
+ * @return 接口返回结果
+ * @throws Throwable
+ */
+
+ @Around("apiPointCut()")
+ public Object apiLog(ProceedingJoinPoint point) throws Throwable {
+ Object proceed = null;
+ if (ObjectUtil.isNotNull(monitor)) {point = (ProceedingJoinPoint) monitor.getPoint(point, request);}
+
+ try {
+ proceed = point.proceed();
+ } finally {
+ log.info("[请求API:[{}],请求参数:[{}],返回结果:[{}]]", request.getRequestURI(), Arrays.toString(point.getArgs()),proceed);
+ }
+ return proceed;
+ }
+
+ /**
+ * 全局异常的监控
+ * @param point 切点
+ */
+ @Before("exceptionPointCut()")
+ public void exceptionLog(JoinPoint point) {
+ log.error("[请求错误API:[{}],错误类型:[{}],错误原因:[{}]]", request.getRequestURI(), point.getSignature().toString(), Arrays.toString(point.getArgs()));
+ }
+
+}
diff --git a/src/main/java/com/template/core/log/MonitorAPI.java b/src/main/java/com/template/core/log/MonitorAPI.java
new file mode 100644
index 0000000..a8360e5
--- /dev/null
+++ b/src/main/java/com/template/core/log/MonitorAPI.java
@@ -0,0 +1,13 @@
+package com.template.core.log;
+
+import jakarta.servlet.http.HttpServletRequest;
+import org.aspectj.lang.JoinPoint;
+
+/**
+ * 获取监控API对象,假如对某个IP进行监控,如果不操作就返回空
+ * @author xxl
+ * @since 2023/9/16
+ */
+public interface MonitorAPI {
+ JoinPoint getPoint(JoinPoint joinPoint, HttpServletRequest request);
+}
diff --git a/src/main/java/com/template/core/redis/config/RedisConfig.java b/src/main/java/com/template/core/redis/config/RedisConfig.java
new file mode 100644
index 0000000..06e9094
--- /dev/null
+++ b/src/main/java/com/template/core/redis/config/RedisConfig.java
@@ -0,0 +1,39 @@
+package com.template.core.redis.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+/**
+ * redis序列化
+ * @author xxl
+ * @since 2023/9/16
+ */
+@Configuration
+public class RedisConfig {
+ /**
+ * 序列化相关的配置
+ */
+ @Bean
+ public RedisTemplate redisTemplate(RedisConnectionFactory factory) {
+ RedisTemplate redisTemplate = new RedisTemplate<>();
+ //支持事务
+ redisTemplate.setEnableTransactionSupport(true);
+ //json方式序列化
+ Jackson2JsonRedisSerializer