-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dc326d9
commit 44b53f2
Showing
21 changed files
with
869 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
!*/ | ||
|
||
|
||
|
||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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脚本 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>3.1.3</version> | ||
<relativePath/> <!-- lookup parent from repository --> | ||
</parent> | ||
|
||
<groupId>com.xxl</groupId> | ||
<artifactId>springboot-template</artifactId> | ||
<version>version:3.1.3</version> | ||
|
||
|
||
<name>springboot-template</name> | ||
<description>spring boot项目模板</description> | ||
|
||
<properties> | ||
<!-- 通用设置 --> | ||
<java.version>17</java.version> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
<maven.compiler.source>17</maven.compiler.source> | ||
<maven.compiler.target>17</maven.compiler.target> | ||
<!-- 依赖版本 --> | ||
<com.github.xiaoymin.version>4.2.0</com.github.xiaoymin.version> | ||
<com.baomidou.version>3.5.3.1</com.baomidou.version> | ||
<pagehelper-spring-boot-starter.version>1.4.6</pagehelper-spring-boot-starter.version> | ||
<cn.hutool.version>5.8.20</cn.hutool.version> | ||
</properties> | ||
<dependencies> | ||
<!-- spring web --> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<!-- JDBC API --> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-jdbc</artifactId> | ||
</dependency> | ||
<!-- mysql --> | ||
<dependency> | ||
<groupId>com.mysql</groupId> | ||
<artifactId>mysql-connector-j</artifactId> | ||
<scope>runtime</scope> | ||
</dependency> | ||
<!-- mybatis-plus --> | ||
<dependency> | ||
<groupId>com.baomidou</groupId> | ||
<artifactId>mybatis-plus-boot-starter</artifactId> | ||
<version>${com.baomidou.version}</version> | ||
</dependency> | ||
<!-- aop --> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-aop</artifactId> | ||
</dependency> | ||
<!-- jsr303依赖 --> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-validation</artifactId> | ||
</dependency> | ||
<!-- hutool --> | ||
<dependency> | ||
<groupId>cn.hutool</groupId> | ||
<artifactId>hutool-all</artifactId> | ||
<version>${cn.hutool.version}</version> | ||
</dependency> | ||
<!-- 分页 --> | ||
<dependency> | ||
<groupId>com.github.pagehelper</groupId> | ||
<artifactId>pagehelper-spring-boot-starter</artifactId> | ||
<version>${pagehelper-spring-boot-starter.version}</version> | ||
</dependency> | ||
<!-- knife4j文档 --> | ||
<dependency> | ||
<groupId>com.github.xiaoymin</groupId> | ||
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId> | ||
<version>${com.github.xiaoymin.version}</version> | ||
</dependency> | ||
<!-- spring boot集成redis依赖 jedis是BIO lettuce是NIO--> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-data-redis</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
<configuration> | ||
<excludes> | ||
<exclude> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
</exclude> | ||
</excludes> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} | ||
} |
Oops, something went wrong.