大部分时间使用正常,偶尔会出现404。我不知道如何定位这个问题。*
Controller.
@RestController
@RequestMapping("/auth")
@RequiredArgsConstructor
public class AuthController {
private final AuthService authService;
@GetMapping("info")
public Result info(@RequestParam("token") String token) {
Map<String, Object> stringObjectMap = authService.getInfo(token);
return ResultGenerator.success(stringObjectMap);
}
}
GET: localhost:9000/auth/info?token=gNGLJLLZsluDsIQw
这个错误信息不时地显示出来。
{
"timestamp": "2021-06-29T06:46:35.477+0000",
"status": 404,
"error": "Not Found",
"message": "No message available",
"path": "/auth/info"
}
版本信息:
- spring boot: 2.2.6.RELEASE
- spring cloud: Hoxton.SR1
Add:
spring cloud gateway yml 配置:
spring:
application:
name: gateway-service
cloud:
nacos:
discovery:
server-addr: localhost:8848
gateway:
default-filters:
- DedupeResponseHeader=Access-Control-Allow-Origin
globalcors:
cors-configurations:
"[/**]":
allowCredentials: true
allowedOrigins: "*"
allowedHeaders: "Origin, X-Requested-With, Content-Type, Accept, Content-Length, TOKEN, Authorization"
allowedMethods: "GET, POST, PATCH, PUT, DELETE, OPTIONS"
maxAge: 3628800
discovery:
locator:
enabled: true
lower-case-service-id: true
routes:
- id: auth-service
uri: lb://auth-service
predicates:
- Path=/v1/auth/**
filters:
- StripPrefix=1
- id: bus-service
uri: lb://bus-service
predicates:
- Path=/v1/**
filters:
- StripPrefix=1
StackOverflow:java - spring boot api return 404 Not Found time to time - Stack Overflow