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:
总结收集到的解决方案:
一、确认swagger实现类所在的module是否被主要的项目或者module所引用,要在自己的包项目下引入swagger所在的module的位置,确保运行的application能访问到swagge。
二、确认swagger实现类加swaggerConfig注解
@Configuration //配置类
@EnableSwagger2 //swagger注解
public class SwaggerConfig {
三、确认Application启动类文件的位置不在子包外

四、确认Application类文件加了@ComponentScan(basePackages = {“xxxx”})注解
五、pom.xml中,swagger的版本问题导致的,换2.6.1之后的版本。
文章讲述了在集成Swagger后遇到的无法推断基础URL的错误,提供了五种解决方案,包括检查swagger模块的引用,确保swagger配置类正确,确认Application启动类位置,添加@ComponentScan注解以及解决Swagger版本可能导致的问题。
2万+

被折叠的 条评论
为什么被折叠?



