ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
**1. 定义文档基本信息** ```java @Configuration public class SpringDocConfig { @Bean public OpenAPI customOpenAPI() { OpenAPI api = new OpenAPI(); api.info( new Info() .title("文档标题") .description("文档描述") .contact(new Contact().name("作者").email("邮箱").url("博客地址")) //许可证 .license(new License().name("Apache 2.0").url("https://www.apache.org/licenses/LICENSE-2.0.html")) //文档版本 .version("v1.0.0") ) .externalDocs(new ExternalDocumentation() .description("外部文档") .url("https://springdoc.org/") ); return api; } } ``` ![](https://img.kancloud.cn/4d/a2/4da22190cd423c0cdaab7c098888903e_1747x629.png) <br/> **2. 文档分组** ```java @Configuration public class SpringDocConfig { @Bean public GroupedOpenApi stuGroup() { return GroupedOpenApi.builder() //接口名称 .group("学生接口") //匹配的路径 .pathsToMatch("/student/**") //扫描的包 .packagesToScan("learn.springdoc.controller") .build(); } @Bean public GroupedOpenApi accuGroup() { return GroupedOpenApi.builder() //接口名称 .group("账号接口") //匹配的路径 .pathsToMatch("/account/**") //扫描的包 .packagesToScan("learn.springdoc.controller") .build(); } } ``` ![](https://img.kancloud.cn/1f/ba/1fba1c4739e82e8e43a34d317791f57b_2474x1121.png)