升级到 spring boot 3.2.10 和 springdoc-openapi-starter-webflux-ui 2.2.0 后,无法加载 swagger UI 并出现以下错误:
org.springframework.web.servlet.resource.NoResourceFoundException: No static resource swagger-ui/index.html.
以下是使用的配置:
pom 依赖项:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.10</version>
<relativePath />
<!-- lookup parent from repository -->
</parent>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webflux-ui</artifactId>
<version>2.2.0</version>
<exclusions>
<exclusion>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
招摇配置:
@Configuration
public class SwaggerConfig {
@Value("${Host:}")
private String configUrl;
@Bean
public OpenAPI OpenApi() {
Contact contact = new Contact();
contact.setName("Team ");
contact.setEmail("email.com");
OpenAPI openAPI = new OpenAPI();
if (StringUtils.isNotEmpty(configUrl)) {
openAPI.addServersItem(
new Server().url(configUrl));
}
openAPI.info(new Info().title(" Scheduler API")
.description("To schedulejobs").version("0.0.1-SNAPSHOT")
.contact(contact)
);
return openAPI;
}
}
将 springdoc-openapi-starter-webflux-ui 更改为 springdoc-openapi-starter-webmvc-ui