Unable to infer base url. This is common when using dynamic servlet registration or when the API is

 swagger 版本

2.9.2
        
            io.springfox
            springfox-swagger2
            ${swagger.version}
        

        
            io.springfox
            springfox-swagger-ui
            ${swagger.version}
        

 swagger 配置

import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;


@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo()).select()
                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("微服务后台API文档")
                .description("生产者")
                .version("2.0.0")
                .build();
    }

}

 

Unable to infer base url. This is common when using dynamic servlet registration or when the API is_第1张图片

 

原因:项目SpringApplication中加上了@ComponentScan注解

 

Unable to infer base url. This is common when using dynamic servlet registration or when the API is_第2张图片

 

为了扫描  mapper 接口   不用 @ComponentScan  换成  @MapperScan 即可Unable to infer base url. This is common when using dynamic servlet registration or when the API is_第3张图片

 

你可能感兴趣的:(随笔)