赞
踩
Springboot3.2.0版本中不在支持swagger2的格式。
- 、、、、、、、、、这个有ui界面 这是springboot 2 项目 需要配置swagger2文件
-
- <!-- 引入 swagger-->
- <dependency>
- <groupId>io.springfox</groupId>
- <artifactId>springfox-swagger2</artifactId>
- <version>2.7.0</version>
- </dependency>
- <dependency>
- <groupId>io.springfox</groupId>
- <artifactId>springfox-swagger-ui</artifactId>
- <version>2.7.0</version>
- </dependency>
- @Configuration
- @EnableSwagger2
- public class Swagger2Config {
-
- @Bean
- public Docket docket() {
- return new Docket(DocumentationType.SWAGGER_2);
- }
- }
- 、、、、、、、、、、 这个是springboot3项目 没有任何配置直接使用
-
- <!-- 引入 swagger-->
- <dependency>
- <groupId>org.springdoc</groupId>
- <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
- <version>2.0.2</version>
- </dependency>
-
- <dependency>
- <groupId>org.springdoc</groupId>
- <artifactId>springdoc-openapi-starter-webmvc-api</artifactId>
- <version>2.0.2</version>
- </dependency>
然后启动成功后直接登录 http://ip:post/swagger-ui.html即可
从Springfox迁移过来的,需要修改注解:
@Api → @Tag
@ApiIgnore → @Parameter(hidden = true) or @Operation(hidden = true) or @Hidden
@ApiImplicitParam → @Parameter
@ApiImplicitParams → @Parameters
@ApiModel → @Schema
@ApiModelProperty(hidden = true) → @Schema(accessMode = READ_ONLY)
@ApiModelProperty → @Schema
@ApiOperation(value = "foo", notes = "bar") → @Operation(summary = "foo", description = "bar")
@ApiParam → @Parameter
@ApiResponse(code = 404, message = "foo") → @ApiResponse(responseCode = "404", description = "foo")
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。