springboot集成swagger2启动项目后报错:
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的模块,但是主启动类无法扫描到swagger的木块,所以找不到。
解决办法:扫描com.topgeeker下面的所有类,包括依赖进来的类
@SpringBootApplication(scanBasePackages = "com.xxxxx")
public class ServiceEduApplication {
public static void main(String[] args) {
SpringApplication.run(ServiceEduApplication.class, args);
}
}
然后现在错误改为:
org.springframework.context.ApplicationContextException: Failed to start bean ‘documentationPluginsBootstrapper’; nested exception is java.lang.NullPointerException
在配置文件中添加一下配置
spring
mvc:
pathmatch:
matching-strategy: ant_path_matcher
问题解决。