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/ 欢迎转载,一起技术交流探讨!