只有在实现类上不使用 任何
jax-rs注释时,才可以使用注释继承:JSR-339的3.6节对此进行了说明。
您重新定义,
@Path并
@Produces为方法重新定义,但不为类重新定义 。
因此,
Path代码中的注释应该在具体的类上:
public interface UserService { @GET @Path("/{userId}") @Produces(MediaType.APPLICATION_JSON) public Response getUser(@PathParam("userId") Long userId);}@Path("/user")class UserServiceImpl implements UserService { @Override @GET @Path("/{userId}") @Produces(MediaType.APPLICATION_JSON) public Response getUser(@PathParam("userId") Long userId) { // TODO Auto-generated method stub return null; }}顺便说一句,规范鼓励我们在具体的类上复制注释:
为了与其他Java EE规范保持一致,建议始终重复注释,而不要依赖注释继承。



