我正在使用弹簧靴1.5.3以及侧摇杆2.7.0(无法升级,因为更高版本无法在IE上运行) 我一切正常,但是当我添加自定义HandlerInterceptorAdapter时,它无法正常工作,给我这个错误:
无法读取null springfox.js的属性'validatorUrl':72
这是我的招摇配置
$myval=$this->input->get('track', TRUE);
这是给我带来麻烦的配置
@Configuration
@EnableSwagger2
public class SwaggerConfig {
public Docket api() {
Docket docket = new Docket(DocumentationType.SWAGGER_2).select()
.apis(RequestHandlerSelectors
.basePackage("net.guides.springboot2.springboot2swagger2.controller"))
.paths(PathSelectors.regex("/.*"))
.build().apiInfo(apiEndPointsInfo());
docket.ignoredParameterTypes(HttpServletResponse.class, HttpServletRequest.class); // this didnt help
return docket;
}
private ApiInfo apiEndPointsInfo() {
return new ApiInfoBuilder().title("SWAT Rest API")
.description("SWAT Rest API documentation")
.contact(new Contact("xxx", "xxxx", "xxxxx"))
.license("Apache 2.0")
.licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html")
.version("5.2.2")
.build();
}
}
如果这里需要的是拦截器类
@Configuration
@Slf4j
public class SwatStaticResourceConfig extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
log.debug("Adding static folders to serve images");
// registry.addResourceHandler("/images/**").addResourceLocations("file:./images/");
//registry.addResourceHandler("/docs/**").addResourceLocations("file:./docs/");
registry.addResourceHandler("/images/**", "/docs/**").addResourceLocations("file:./images/", "file:./docs/");
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new SwatRequestInterceptor()); // if i disable this line than swagger is working fine
super.addInterceptors(registry);
}
}
答案 0 :(得分:0)
我遇到了同样的问题,但是通过确保仅单个类扩展WebMvcConfigurationSupport来解决此问题,最好是在您注册拦截器的地方。 另外,请确保为swagger config类添加以下内容:
@Override 公共无效addResourceHandlers(ResourceHandlerRegistry注册表){ Registry.addResourceHandler(“ swagger-ui.html”)。addResourceLocations(“ classpath:/ META-INF / resources /”); Registry.addResourceHandler(“ / webjars / **”)。addResourceLocations(“ classpath:/ META-INF / resources / webjars /”); }