gpt4 book ai didi

不使用最新版本的 Spring Boot SwaggerUI

转载 作者:行者123 更新时间:2023-12-04 04:00:42 32 4
gpt4 key购买 nike

我正在尝试在我的 Spring Boot 应用程序中添加 Swagger UI,但我无法访问 swagger-ui.html。

pom.xml

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.1.RELEASE</version>
</parent>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-spring-webflux</artifactId>
<version>3.0.0</version>
</dependency>

代码:

@Configuration
public class SwaggerConfig {

@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2).select()
.apis(RequestHandlerSelectors.basePackage("com.learnings.search.web")).build().pathMapping("/")
.enableUrlTemplating(false);
}

}


@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class, CassandraAutoConfiguration.class,
KafkaAutoConfiguration.class })
@EnableSwagger2
public class SearchApp {

public static void main(String[] args) {
SpringApplication.run(SearchApp.class, args);
}
}

我能够访问 swagger 资源:

/swagger-resources
[
{
"name": "default",
"url": "/v2/api-docs",
"swaggerVersion": "2.0",
"location": "/v2/api-docs"
}
]


/swagger-resources/configuration/ui
{
"deepLinking": true,
"displayOperationId": false,
"defaultModelsExpandDepth": 1,
"defaultModelExpandDepth": 1,
"defaultModelRendering": "example",
"displayRequestDuration": false,
"docExpansion": "none",
"filter": false,
"operationsSorter": "alpha",
"showExtensions": false,
"showCommonExtensions": false,
"tagsSorter": "alpha",
"validatorUrl": "",
"supportedSubmitMethods": [
"get",
"put",
"post",
"delete",
"options",
"head",
"patch",
"trace"
],
"swaggerBaseUiUrl": ""
}

如果最新版本有什么变化请告诉我,因为我在其他项目中一直在使用 swagger-ui。

最佳答案

在 3.0.0 中,swagger-ui.html 已移至 swagger-ui/index.html

关于不使用最新版本的 Spring Boot SwaggerUI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63080599/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com