【发布时间】:2021-10-17 17:02:29
【问题描述】:
我最近了解到 JAX-RS 和 jersey 是它的实现之一。到目前为止,我一直在使用 Spring boot 来使用 rest api。
我只是在尝试将两个依赖项放在一起。所以我的 pom 看起来像:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
现在我添加了一个具有如下端点的控制器:
@Service
@Path("/")
@RestController
public class TestController {
@GET
@Path("/test")
public String test() {
return "Hello World";
}
@GetMapping("/test2")
public String test2() {
return "Hello World - spring";
}
}
现在,如果我尝试像这样热这些端点:
http://localhost:8080/test
和
http://localhost:8080/test2
我只收到 jersey 的回复(“Hello World”)。
任何人都可以帮助我了解它如何注册这些端点以及为什么 @GetMapping 端点没有被识别。
谢谢。
【问题讨论】:
标签: spring spring-boot jersey