Spring 在RestController中找不到映射

Spring 在RestController中找不到映射,spring,spring-boot,rest,spring-restcontroller,Spring,Spring Boot,Rest,Spring Restcontroller,我有一个RestController,它定义了一个默认路径和一些端点,如下所示: @RestController @EnableHypermediaSupport(type = EnableHypermediaSupport.HypermediaType.HAL) @RequestMapping(path = "/somePath", produces = "application/hal+json") public class SomeRestController { @GetMappi

我有一个RestController,它定义了一个默认路径和一些端点,如下所示:

@RestController
@EnableHypermediaSupport(type = EnableHypermediaSupport.HypermediaType.HAL)
@RequestMapping(path = "/somePath", produces = "application/hal+json")
public class SomeRestController {

  @GetMapping (path = "/otherPath")
  public String someEndpoint(){
  return "hello";
  }

    ...other endpoints...
}
我得到了一个404的映射端点。但是,如果我删除默认的RequestMapping,端点会突然被拾取!我还尝试了端点的RequestMapping(path=…,method=RequestMethod.GET),但结果相同

如果从一个端点删除@GetMapping,则默认路径将成功映射


这是怎么回事?如果我有默认的RequestMapping,为什么端点不被映射?

您必须同时连接两个路径:

localhost:8080/somePath/otherPath

由于类顶部的映射适用于此控制器中的所有方法,因此将添加特定于方法的路径

如何调用控制器?GET for localhost:8080/otherPath此操作有效,如果我删除默认的RequestMapping(/somePath),则此控制器中每个API的URL中都应包含默认的RequestMapping路径