找不到/get/swagger的Map

falq053o  于 2021-07-11  发布在  Java
关注(0)|答案(1)|浏览(493)

我正在尝试为项目配置swagger,但收到错误无数次:

o.s.web.servlet.PageNotFound             : No mapping for GET /project1/api/null/swagger-resources/configuration/ui" 
o.s.web.servlet.PageNotFound             : No mapping for GET /project1/api/null/swagger-resources/configuration/ui" 
o.s.web.servlet.PageNotFound             : No mapping for GET /project1/api/null/swagger-resources/configuration/ui" 
o.s.web.servlet.PageNotFound             : No mapping for GET /project1/api/null/swagger-resources/configuration/ui" 
................

我有一个多项目层。结构为:
项目名称
--项目1

--setting.gradle

  --build.gradle

--项目2

--setting.gradle

  --build.gradle

--设置.gradle
在每个build.gradle中,我都有以下依赖项:

compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.2'
compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.9.2'

swaggerconfiguration类是:

@EnableSwagger2
@Configuration
public class SwaggerConfiguration {

    @Bean
    public Docket productApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any())
                .build()
                .pathMapping("/");
    }
}

我还有一个网络配置课程:

@Configuration
@EnableWebMvc
@Slf4j
public class WebConfigure extends WebMvcConfigurationSupport {
    @Bean
    public AuthorizationInterceptor requestInterceptor() {
        return new AuthorizationInterceptor();
    }

    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        log.info("Adding interceptor [{}]", AuthorizationInterceptor.class.getName());
        registry.addInterceptor(requestInterceptor());
    }

    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("swagger-ui.html")
                .addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**")
        .addResourceLocations("classpath:/META-INF/resources/webjars/");
    }
}

如果我尝试访问http://localhost:8090/project1/api/swagger-ui.html我收到此错误:
招摇错误

lo8azlld

lo8azlld1#

从server.servlet.context-path中删除“/api”。
不知怎的,招摇和那部分有冲突。

相关问题