简体   繁体   English

接口和实现的不同媒体类型

[英]Different media type for interface and implementation

I have below code INTERFACE consuming application xml 我在下面的代码INTERFACE消耗应用程序xml

@Path("/user")
public interface UserService {
@CONSUMES(MediaType.APPLICATION_XML)
    @POST
    @Path("/{userId}")
    public Response creaTeUser(@PathParam("userId") Long userId);

}
 I have implementation which consume application JSON

class UserServiceImpl implements UserService {

    @Override
    @POST
    @Path("/{userId}")
@CONSUMES(MediaType.APPLICATION_JSON)
    public Response getUser(@PathParam("userId") Long userId) {
        // TODO Auto-generated method stub
        return null;
    }

}

when i do post user what will be actual media type 当我发布用户信息时,实际的媒体类型是什么

Java method annotations do not support inheritance, so your media type would be application/json . Java方法注释不支持继承,因此您的媒体类型为application/json See this answer: Why java classes do not inherit annotations from implemented interfaces? 看到这个答案: 为什么Java类不从实现的接口继承注释?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM