SpringBoot集成Swagger2出现的一些问题

  1. 页面总是报红,提示post请求下缺少文档:post请求一定是传入了较为复杂的参数,所以需要在@ApiImplicitParam注释里增加参数allowMultiple=true;
  2. swagger-ui.html页面显示不出来:
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@SuppressWarnings("deprecation")
@Configuration
public class WebMvcConfig extends WebMvcConfigurerAdapter {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");

        registry.addResourceHandler("swagger-ui.html")
                .addResourceLocations("classpath:/META-INF/resources/");

        registry.addResourceHandler("/webjars/**")
                .addResourceLocations("classpath:/META-INF/resources/webjars/");

    }
}
不管怎么样,遇到问题就要多去尝试各种方法去解决

你可能感兴趣的:(我遇到的问题)