【注解问题】Swagger-ui.html启动报错:Unable to infer base url. This is common when using dynamic servlet..

  Spring Boot模块的某个功能接口开发完毕,配置好Swagger相关信息,启动报错:

  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:

弹窗:

在这里插入图片描述
我的基础配置:

(1)pom文件加入了依赖

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

(2)config文件配置文档信息

@Configuration
@EnableSwagger2
public class Swagger2Config {
  
    @Bean
    public Docket webApiConfig() {
    .....
    }
 }

报错根源–我的启动类没有加入注解!!!

@EnableSwagger2  //加入EnableSwagger2 
@EnableEurekaClient
@SpringBootApplication
public class EduCenterApplication {
    public static void main(String[] args) {
        SpringApplication.run(EduCenterApplication.class);
    }
}

(3)浏览器测试功能!

在这里插入图片描述

♚学习、实战、总结、分享,让生活变得更美好!
☞林大侠博客:https://coding0110lin.blog.csdn.net/  欢迎转载,一起技术交流探讨!

  • 13
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 8
    评论
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值