Bug:No mapping for GET /onepill//swagger-ui.html

Posted 两小无猜

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Bug:No mapping for GET /onepill//swagger-ui.html相关的知识,希望对你有一定的参考价值。

SpringBoot使用Swagger2本来可以使用的,后来出现的异常No mapping for GET /swagger-ui.html,这个异常其实不用怎么解释,说白了就是找不到了。

遇到这种情况请先查找,最近你所添加继承了【WebMvcConfigurationSupport】的类
如果继承了WebMvcConfigurationSupport,则在配置文件在中配置的相关内容会失效,需要重新指定静态资源
需要重新指定swagger静态资源

@Configuration
public class WebMvcConfigurer extends WebMvcConfigurationSupport {

    /**
     * 发现如果继承了WebMvcConfigurationSupport,则在yml中配置的相关内容会失效。 需要重新指定静态资源
     *
     * @param registry
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/**").addResourceLocations(
                "classpath:/static/");
        registry.addResourceHandler("swagger-ui.html").addResourceLocations(
                "classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**").addResourceLocations(
                "classpath:/META-INF/resources/webjars/");
        super.addResourceHandlers(registry);
    }
}

虽然不懂原因,但是很有用。

以上是关于Bug:No mapping for GET /onepill//swagger-ui.html的主要内容,如果未能解决你的问题,请参考以下文章

编程中易中招的bug总结

error: No implicit Ordering defined for Any

错误:No Dialect mapping for JDBC type: -9

This application has no explicit mapping for 解决方法

This application has no explicit mapping for 解决方法

A query was run and no Result Maps were found for the Mapped Statement....