久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術(shù)文章
文章詳情頁

Spring Boot Swagger2使用方法過程解析

瀏覽:103日期:2023-08-20 14:06:21

1.添加Swagger2依賴

<dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.2.2</version></dependency><dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.2.2</version></dependency>

2配置類

@Configuration@EnableSwagger2public class Swagger2 { @Bean public Docket createRestApi() { return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select().apis(RequestHandlerSelectors.basePackage('com.bs.swaggertest.controller')).paths(PathSelectors.any()).build(); } private ApiInfo apiInfo() { return new ApiInfoBuilder().title('微信項目接口對接文檔').description('測試環(huán)境接口調(diào)試').contact('陶海軍').version('1.0').build(); }}

3.添加文檔內(nèi)容

@RestController@RequestMapping(value='/users')public class UserController { @ApiOperation(value='刪除用戶', notes='根據(jù)url的id來指定刪除對象') @ApiImplicitParam(name = 'id', value = '用戶ID', required = true, dataType = 'String') @RequestMapping(value='/{id}', method=RequestMethod.DELETE) public String deleteUser(@PathVariable String id) { return 'success'; }}

4.測試

http://localhost:8080/swagger-ui.html

Spring Boot Swagger2使用方法過程解析

Spring Boot Swagger2使用方法過程解析

Spring Boot Swagger2使用方法過程解析

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: Spring
相關(guān)文章:
主站蜘蛛池模板: 丽江市| 贵德县| 宿州市| 维西| 怀化市| 安龙县| 河北省| 砀山县| 楚雄市| 宣化县| 华亭县| 大埔区| 蓝田县| 大余县| 罗城| 广昌县| 麦盖提县| 岫岩| 海宁市| 镇康县| 阿合奇县| 赤峰市| 梁山县| 平安县| 阿克苏市| 武汉市| 民乐县| 启东市| 连平县| 凭祥市| 南涧| 额敏县| 深水埗区| 新疆| 沂源县| 滨海县| 嘉义县| 阿坝县| 南康市| 霍城县| 福鼎市|