等级:
implementation group: 'org.springdoc', name: 'springdoc-openapi-ui', version: '1.6.13'
implementation group: 'io.swagger.core.v3', name: 'swagger-annotations', version: '2.2.7'
属性:
springdoc.swagger-ui.enabled=true
springdoc.swagger-ui.path=/swagger-ui.html
控制器:
@RestController
@RequestMapping("/api/v1/cheque")
@FieldDefaults(level = AccessLevel.PRIVATE,makeFinal = true)
public class ChequeController {
ProductService productService;
public ChequeController(ProductService productService) {
this.productService = productService;
}
@GetMapping(value = "/get/{id}", produces = "application/json")
public Optional<Product> getByid(@PathVariable Long id) {
return productService.getById(id);
}
@GetMapping("/test")
public String test() {
return "test";
}
}
型
置信度:
@Configuration
public class OpenApiConfiguration {
@Bean
public OpenAPI customOpenAPI() {
return new OpenAPI()
.info(
new Info()
.title("Example Swagger Api")
.version("1.0.0")
);
}
}
尝试在localhost:8080/swagger-ui.html
中打开并获得:Whitelabel Error Page There was an unexpected error (type=Not Found, status=404).
https://springdoc.org/#getting-started,它会自动将swagger-ui部署到一个 Spring 启动的应用程序中
我做错了什么
1条答案
按热度按时间oprakyz71#
对于swagger v3+,swagger ui的默认访问权限现在是
swagger-ui/
而不是swagger-ui.html
您应该可以通过将url修改为localhost:8080/swagger-ui/
来访问