Knife4j与WebMvcConfigurationSupport冲突

kyaa111 发布于 04/07 20:06
阅读 122
收藏 0
@Component
public class AppWebMvcConfigurationSupport extends WebMvcConfigurationSupport {

    /**
     * Controller 方法参数注入
     *
     * @param argumentResolvers
     */
    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
        argumentResolvers.add(new HandlerMethodArgumentResolver() {
            @Override
            public boolean supportsParameter(MethodParameter parameter) {
                return parameter.hasParameterAnnotation(Cache.class);
            }

            @Override
            public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest,
                                          WebDataBinderFactory binderFactory) throws Exception {
                HttpServletRequest request = (HttpServletRequest) webRequest.getNativeRequest();

                return JwtUtils.getxxxxFromRequest(request);
            }
        });
    }

}
@Configuration
@EnableSwagger2WebMvc
public class Knife4jConfig {

    @Bean
    public Docket defaultApi() {
        return new Docket(DocumentationType.SWAGGER_2).host("http://localhost:8080").groupName("1.0").select()
            .apis(RequestHandlerSelectors.basePackage("top.xxx.local.web")).paths(PathSelectors.any()).build();
    }
}

参数注入生效, 但knife4j的页面报404

加载中
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部