大纲

目录结构如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
blog-springboot
├── annotation -- 自定义注解
├── aspect -- aop模块
├── config -- 配置模块
├── constant -- 常量模块
├── consumer -- MQ消费者模块
├── controller -- 控制器模块
├── dao -- 框架核心模块
├── dto -- dto模块
├── enums -- 枚举模块
├── exception -- 自定义异常模块
├── handler -- 处理器模块(扩展Security过滤器,自定义Security提示信息等)
├── service -- 服务模块
├── strategy -- 策略模块(用于扩展第三方登录,搜索模式,上传文件模式等策略)
├── util -- 工具类模块
└── vo -- vo模块

1、接口文档

Knife4j

knife4j是为Java MVC框架集成Swagger生成Api文档的增强解决方案,前身是swagger-bootstrap-ui

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.minzheng.blog.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
import java.util.Collections;

/**
* Knife4j配置类
*
* @author yezhiqiu
*/
@Configuration
@EnableSwagger2WebMvc
public class Knife4jConfig {

@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.protocols(Collections.singleton("https"))
.host("https://www.talkxj.com")
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("com.minzheng.blog.controller"))
.paths(PathSelectors.any())
.build();
}

private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("博客api文档")
.description("springboot+vue开发的博客项目")
.contact(new Contact("风丶宇", "https://github.com/X1192176811", "1192176811@qq.com"))
.termsOfServiceUrl("https://www.talkxj.com/api")
.version("1.0")
.build();
}

}