首先,您应该注册swagger的资源。
@Configurationpublic class WebMvcConfig extends WebMvcConfigurerAdapter { @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("swagger-ui.html") .addResourceLocations("classpath:/meta-INF/resources/"); }}然后,因为您正在使用Spring Security,也许您应该关闭特权。
@Override public void configure(WebSecurity web) throws Exception { web.ignoring().mvcMatchers(HttpMethod.OPTIONS, "/**"); // ignore swagger web.ignoring().mvcMatchers("/swagger-ui.html/**", "/configuration/**", "/swagger-resources/**", "/v2/api-docs"); }也许最好使用版本低于2.8.0的swagger,否则您可能不得不面对许多错误。



