zuul抛出404无会议可用错误

nle07wnf  于 2021-07-15  发布在  Java
关注(0)|答案(1)|浏览(309)

我有我下面的应用程序(微服务),它已成功注册到eureka服务器。我有下面的rest端点

@Controller
@RequestMapping("v1/base/")
public class PersonController {

    @PostMapping
    @RequestMapping(value="/personid")
    public ResponseEntity< ?> getPersonList(){
        return ResponseEntity.ok("All person list");
    }

person应用程序的属性文件

eureka:
  instance:
    appname: person-application
  client:
    enabled: true
    register-with-eureka: true
    fetch-registry: true
    service-url:
      defaultZone: http://localhost:8761/eureka/

我的zuul服务器yml文件配置是。

server:
        port:9000
        servlet:
         contextPath: /zuulapp

   zuul:
      routes:
         person:
            path: /v1/base/**
            serviceId: person-application

当我打电话的时候,打到休息点localhost:9000/zuulapp/person/personid 我得到下面的错误。我如何解决这个错误

{
   "timestamp":"2019-10-08T12:42:09.479+0000",
   "status":404,
   "error":"Internal Server Error",
   "message":"No Message available"
   "path" : "/zuulapp/person/personid"
}
r1zk6ea1

r1zk6ea11#

因为应用程序zuul中的注册路径是“/v1/base/**”
尝试以下方法:删除contextpath属性,然后用zuul.prefix属性替换它。

server:
        port:9000

   zuul:
      prefix: /zuulapp
      routes:
         person:
            path: /person/**
            serviceId: person-application

现在尝试检查此终结点:
localhost:9000/zuulapp/person/v1/base/personid
在控制器类中尝试以下操作:

@RestController
@RequestMapping("/v1/base/")
public class PersonController {

    @GetMapping(value="/personid")
    public ResponseEntity< ?> getPersonList(){
        return ResponseEntity.ok("All person list");
    }

相关问题