springBoot 配置SwaggerUi接口测试
1. 通过maven导入jar包
<!-- 引入swagger相关的jar --> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.9.2</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.9.2</version> </dependency>
2. 编写SwaggerConfig配置文件
@Configuration @EnableSwagger2 public class SwaggerConfig { @Bean public Docket createRestApi(){ return new Docket(DocumentationType.SWAGGER_2) .pathMapping("/") .select() .apis(RequestHandlerSelectors.basePackage("com.tw.skynet.controller")) //项目接口类路径 .paths(PathSelectors.any()) .build().apiInfo(new ApiInfoBuilder() .title("API接口调试") .description("详细信息") .version("1.0") .contact(new Contact( "drgs", //项目名称 "https://www.00.cn", //备注网址 "11111111111@163.com")) //备注邮箱地址 .license("The Apache License") .licenseUrl("https://www.00.cn") .build() ); } }
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
· SQL Server 2025 AI相关能力初探
· 为什么 退出登录 或 修改密码 无法使 token 失效