pom.xml添加依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
</dependency>
新建配置类JerseyConfig
@Component
@ApplicationPath("")
public class JerseyConfig extends ResourceConfig {
public JerseyConfig(){
register(UserResource.class);
}
}
新建UserResource类
@Component
@Path("/users")
public class UserResource {
@GET
@Produces(MediaType.APPLICATION_JSON)
public String get(){
return "hello cc. i love you";
}
}
启动
输入localhost:8080/users