日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

[Swagger2]SpringBoot集成Swagger

發布時間:2023/12/4 46 豆豆
生活随笔 收集整理的這篇文章主要介紹了 [Swagger2]SpringBoot集成Swagger 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

SpringBoot集成Swagger

引入依賴

<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 --> <dependency><groupId>io.springfox</groupId><artifactId>springfox-swagger2</artifactId><version>2.9.2</version> </dependency> <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui --> <dependency><groupId>io.springfox</groupId><artifactId>springfox-swagger-ui</artifactId><version>2.9.2</version> </dependency>

編寫HelloController,測試確保運行成功!

package com.xxxx.swagger2.controller;import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController;@RestController public class HelloController {@RequestMapping(value = "/hello")public String hello(){return "hello";}}

要使用Swagger,我們需要編寫一個配置類-SwaggerConfig來配置 Swagger

@Configuration //配置類 @EnableSwagger2// 開啟Swagger2的自動配置 public class SwaggerConfig { }

訪問測試 :http://localhost:8080/swagger-ui.html ,可以看到swagger的界面;

總結

以上是生活随笔為你收集整理的[Swagger2]SpringBoot集成Swagger的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。