如何将swaggerUI与spring安全Rest服务集成?

如何将swaggerUI与spring安全Rest服务集成?,swagger,Swagger,这是加载我的项目war文件的RESTAPI的配置类 I have my spring project war which contains Secure REST services.I need to integrate these Rest Services with swagger UI but everytime I am getting an exception like:-"HTTP-401 Full Authenticatuion required to access the res

这是加载我的项目war文件的RESTAPI的配置类

I have my spring project war which contains Secure REST services.I need to integrate these Rest Services with swagger UI but everytime I am getting an exception like:-"HTTP-401 Full Authenticatuion required to access the resource" for my below snippet code:
这是一个控制器类,它具有定制的方法getdocumentation方法,该方法将在内部调用spring控制器并获取我使用springfox swagger ui 2.0 maven依赖项提供的文档

@Configuration
@EnableSwagger2
public class SwaggerConfig extends WebMvcConfigurerAdapter {

    @Bean
    public Docket petApi() {
This is docket class which creates swagger documentation.

        return new Docket(DocumentationType.SWAGGER_2).select().apis(RequestHandlerSelectors.any()).paths(PathSelectors.any()).build()
                    .pathMapping("/").directModelSubstitute(LocalDate.class, String.class).genericModelSubstitutes(ResponseEntity.class);
    }

}
@控制器
公共类虚张声势控制器{
公共静态最终字符串DEFAULT_URL=“/v2/api docs”;
@值(${springfox.documentation.swagger.v2.host:DEFAULT})
私有字符串主机名覆盖;
@自动连线
私有文档缓存文档缓存;
@自动连线
私有服务模型ToSwigger2Mapper映射器;
@自动连线
私人JsonSerializer JsonSerializer;
@RequestMapping(值={“/Vijay”},方法={org.springframework.web.bind.annotation.RequestMethod.GET})
@应答器
public ResponseEntity getDocumentation(@RequestParam(value=“group”,required=false)String-swaggerGroup){
String groupName=可选。fromNullable(swaggerGroup)。或(“默认”);
Documentation Documentation=this.documentationCache.documentationByGroup(groupName);
if(文档==null){
返回新的ResponseEntity(未找到HttpStatus.NOT_);
}
Swagger-Swagger=this.mapper.mapDocumentation(文档);
host(hostName());
返回新的ResponseEntity(this.jsonSerializer.toJson(swagger),HttpStatus.OK);
}
私有字符串主机名(){
if(“DEFAULT”.equals(this.hostNameOverride)){
URI=ControllerLinkBuilder.linkTo(Swagger2Controller.class).toUri();
字符串host=uri.getHost();
int-port=uri.getPort();
如果(端口>-1){
返回String.format(“%s:%d”,新对象[]{host,Integer.valueOf(port)});
}
返回主机;
}
返回此.hostNameOverride;
}
}
如有任何帮助或建议,将不胜感激。假设我已经在相应spring项目的context.xml文件中编写了安全性,比如
但还是得到了如上所述的异常
@Controller
public class Swagger2Controller {

    public static final String DEFAULT_URL = "/v2/api-docs";

    @Value("${springfox.documentation.swagger.v2.host:DEFAULT}")
    private String hostNameOverride;

    @Autowired
    private DocumentationCache documentationCache;

    @Autowired
    private ServiceModelToSwagger2Mapper mapper;

    @Autowired
    private JsonSerializer jsonSerializer;

    @RequestMapping(value = { "/Vijay" }, method = { org.springframework.web.bind.annotation.RequestMethod.GET })
    @ResponseBody
    public ResponseEntity<Json> getDocumentation(@RequestParam(value = "group", required = false) String swaggerGroup) {

        String groupName = Optional.fromNullable(swaggerGroup).or("default");
        Documentation documentation = this.documentationCache.documentationByGroup(groupName);
        if (documentation == null) {
            return new ResponseEntity(HttpStatus.NOT_FOUND);
        }
        Swagger swagger = this.mapper.mapDocumentation(documentation);
        swagger.host(hostName());
        return new ResponseEntity(this.jsonSerializer.toJson(swagger), HttpStatus.OK);
    }

    private String hostName() {

        if ("DEFAULT".equals(this.hostNameOverride)) {
            URI uri = ControllerLinkBuilder.linkTo(Swagger2Controller.class).toUri();
            String host = uri.getHost();
            int port = uri.getPort();
            if (port > -1) {
                return String.format("%s:%d", new Object[] { host, Integer.valueOf(port) });
            }
            return host;
        }
        return this.hostNameOverride;
    }

}

Any Help or suggestion will be highly appreciated. provided I have already written security as non in context.xml file of respective spring project like

<mvc:default-servlet-handler />
    <mvc:resources mapping="/webjars/*" location="classpath:/META-INF/resources/webjars" />
    <mvc:resources mapping="/swagger-resources/*" location="classpath:/META-INF/resources/" />
    <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping" />
    <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter" />
    <bean class="com.swagger.config.SwaggerConfig" />
    <bean class="com.swagger.controller.Swagger2Controller" />

But still getting exception as mentioned above