错误信息为:
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:
出现了这个错误的原因很多,有的人说是版本的原因,但我试了这个方法,发现并没有解决。
最终,我发现是我的项目SpringApplication中加上了@ComponentScan注解,我去掉这个注解后,就可以正常访问了。
还有种可能就是在pom.xml中加入了
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>