问题描述:
新搭建好的springboot项目,导入相关swagger依赖后通过localhost访问。
但访问时报错信息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:
解决方案:
在application启动类中未定义@EnableSwagger2,因为使用的是zuul+swagger,而采用,springboot集成的swagger,都是导入的@EnableSwagger2Doc,所以才报错。
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.7.0</version>
</dependency>