Java @PathParam出现错误
我正在使用Jersey,我有以下两种RESTful方法:Java @PathParam出现错误,java,rest,tomcat,jersey,Java,Rest,Tomcat,Jersey,我正在使用Jersey,我有以下两种RESTful方法: @GET @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public List<Activity> getAllActivities() { return activityRepository.findAllActivities(); } 在我添加第二种方法之前,一切都很顺利。但是,我的tomcat现在给出了以下错误 org.gl
@GET
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public List<Activity> getAllActivities() {
return activityRepository.findAllActivities();
}
在我添加第二种方法之前,一切都很顺利。但是,我的tomcat现在给出了以下错误
org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization.
[[FATAL] A resource model has ambiguous (sub-)resource method for HTTP method GET and input mime-types as defined by @Consumes and @Produces annotations
有什么线索吗?你应该使用@Path(“{activityId}”)
而不是@PathParam(“{activityId}”)
文件指出
@路径参数
将URI模板参数或包含模板参数的路径段的值绑定到资源方法参数、资源类字段或资源类bean属性
@路径
标识资源类或类方法将为其请求提供服务的URI路径
因此,应该使用@Path
来定义资源方法将服务的URI路径
org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization.
[[FATAL] A resource model has ambiguous (sub-)resource method for HTTP method GET and input mime-types as defined by @Consumes and @Produces annotations