0
点赞
收藏
分享

微信扫一扫

解决整合Swagger2弹出框的问题

关于swagger2弹出框内容:

Unable to infer base url. This is common when using dynamic servlet registration or when the API is behind an API Gateway. The base url is the root of where all the swagger resources are served. For e.g. if the api is available at http://example.org/api/v2/api-docs then the base url is http://example.org/api/. Please enter the location manually:

解决整合Swagger2弹出框的问题_java
解决办法:

  • 启动类上加​​@ComponentScan(basePackages = "com.xiaobear")​
@SpringBootApplication
@ComponentScan(basePackages = "com.xiaobear")
public class ServiceHospitalApplication {

public static void main(String[] args) {
SpringApplication.run(ServiceHospitalApplication.class, args);
}
}
  • swagger配置类上加上开启注解
@Configuration
@EnableSwagger2
public class Swagger2Config {
}

再次访问就没有弹窗了:

​​http://localhost:端口号/swagger-ui.html​​


举报

相关推荐

0 条评论