Java Swagger实现spring boot Oauth2问题:404 409
我在我的应用程序(spring boot)中实现了swagger 2,所以我实现了oauth2,它给了我Java Swagger实现spring boot Oauth2问题:404 409,java,spring-boot,swagger,swagger-ui,swagger-2.0,Java,Spring Boot,Swagger,Swagger Ui,Swagger 2.0,我在我的应用程序(spring boot)中实现了swagger 2,所以我实现了oauth2,它给了我承载令牌\u id,然后只有所有api都将被验证 所以,我的招摇过市页面实际上就在那里 正如你所看到的,我在这一页什么也没有得到 我的SwaggerConfig.java文件是 @Configuration @EnableSwagger2 public class SwaggerConfig { ApiInfo apiInfo() { return new ApiI
承载令牌\u id
,然后只有所有api都将被验证
所以,我的招摇过市页面实际上就在那里
正如你所看到的,我在这一页什么也没有得到
我的SwaggerConfig.java文件是
@Configuration
@EnableSwagger2
public class SwaggerConfig {
ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("OSAM")
.description("OSAM")
.license("Apache 2.0")
.licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html")
.termsOfServiceUrl("http://swagger.io/terms/")
.version("1.0.0").contact(new Contact("","", "pb@gmail.com"))
.build();
}
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build()
.enable(true)
.apiInfo(apiInfo())
.securityContexts(Lists.newArrayList(securityContext()))
.securitySchemes(Arrays.asList(securitySchema(), apiKey()));
}
private OAuth securitySchema() {
List<AuthorizationScope> authorizationScopeList = new ArrayList<>();
authorizationScopeList.add(new AuthorizationScope("read", "read all"));
authorizationScopeList.add(new AuthorizationScope("write", "access all"));
List<GrantType> grantTypes = new ArrayList();
GrantType passwordCredentialsGrant = new ResourceOwnerPasswordCredentialsGrant("tokenUrl");
grantTypes.add(passwordCredentialsGrant);
return new OAuth("oauth2", authorizationScopeList, grantTypes);
}
private ApiKey apiKey() {
return new ApiKey("Authorization",
"api_key", "header");
}
private SecurityContext securityContext() {
return SecurityContext.builder()
.securityReferences(defaultAuth())
.forPaths(PathSelectors.regex("/anyPath.*"))
.build();
}
List<SecurityReference> defaultAuth() {
AuthorizationScope authorizationScope
= new AuthorizationScope("global", "accessEverything");
AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
authorizationScopes[0] = authorizationScope;
return Lists.newArrayList(
new SecurityReference("Authorization", authorizationScopes));
}
@Bean
public SecurityConfiguration securityInfo() {
return new SecurityConfiguration(null, null, null, null, "", ApiKeyVehicle.HEADER,"Authorization",": Bearer");
}
}
我的问题是:我缺少什么?如何解决404409错误,
在提供的图片中,它说404409用于几个API如何在spring boot中修复它?
任何帮助都将不胜感激
// https://mvnrepository.com/artifact/io.swagger/swagger-annotations
compile group: 'io.swagger', name: 'swagger-annotations', version: '1.5.22'
// https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui
compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.0.2'
// https://mvnrepository.com/artifact/io.springfox/springfox-swagger2
compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.7.0'
// https://mvnrepository.com/artifact/io.springfox/springfox-bean-validators
compile group: 'io.springfox', name: 'springfox-bean-validators', version: '2.7.0'