在开发时须要配置接口文档,此处用到的是Knife4j

在Security 我的项目配置Knife4j时 须要在security的配置类中配置如下代码

    @Override    public void configure(WebSecurity web) throws Exception {        web.ignoring().antMatchers("/swagger/**")                .antMatchers("/swagger-ui.html")                .antMatchers("/webjars/**")                .antMatchers("/v2/**")                .antMatchers("/v2/api-docs-ext/**")                .antMatchers("/swagger-resources/**")                .antMatchers("/doc.html");    }

当然属于swagger的配置类还是得有的

    @Bean(value = "defaultApi2")    public Docket defaultApi2() {        Docket docket=new Docket(DocumentationType.SWAGGER_2)                .apiInfo(new ApiInfoBuilder()                        //.title("swagger-bootstrap-ui-demo RESTful APIs")                        .description("hr APIs")//                        .termsOfServiceUrl("http://www.xx.com/")                        .contact(new Contact("name",url,"@163.com"))                        .version("1.0")                        .build())                //分组名称                .groupName("0.1版本")                .select()                //这里指定Controller扫描包门路                .apis(RequestHandlerSelectors.basePackage("com.xxx.xxx.controller"))                .paths(PathSelectors.any())                .build();        return docket;    }

配置实现即可拜访

另外,如果配置的是swagger的话(当然下面的也是swagger),须要以下配置

        web.ignoring().antMatchers("/swagger/**")                .antMatchers("/swagger-ui.html")                .antMatchers("/webjars/**")                .antMatchers("/v2/**")                .antMatchers("/swagger-resources/**");