gpt4 book ai didi

java - 找不到 swagger-resources/configuration/ui 的映射

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:28:09 27 4
gpt4 key购买 nike

<分区>

我正在尝试在非 Spring Boot 应用程序中配置 swagger ui。我做了以下事情。1.添加了以下依赖

<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.1.2</version>
</dependency>

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

<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>3.3.5</version>
</dependency>

2。添加了 Swagger 配置类

@Configuration
@EnableSwagger2
@EnableWebMvc
//@PropertySource("classpath:/swagger.properties")
public class SwaggerConfig {

@Bean
public Docket proposalApis(){
return new Docket(DocumentationType.SWAGGER_2)
.groupName("test")
.select()
.apis(RequestHandlerSelectors.basePackage("com.test.abc"))
.paths(PathSelectors.regex("/test1.*"))
.build()
.apiInfo(testApiInfo());
}

private ApiInfo testApiInfo() {
ApiInfo apiInfo = new ApiInfoBuilder().title("Test APIs").description("GET POST PUT methods are supported ").version("V1").build();
return apiInfo;
}
}
  1. 添加了以下映射:

    <mvc:resources mapping="swagger-ui.html" location="classpath:/META-    INF/resources/"/>
    <mvc:resources mapping="/webjars/**" location="classpath:/META- INF/resources/webjars/"/>

我可以访问以下网址

    /v2/api-docs
/swagger-resources

但是在加载 swagger-ui.html 时 UI 被加载并且在服务器上出现以下错误 enter image description here

    No mapping found for /context/swagger-resources/configuration/ui in Dispatcher servlet

有人可以帮忙吗?

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