Open fnet123 opened 8 years ago
代码如下------------------------------------
业务接口: @Path("clientCommentService") @Produces({MediaType.APPLICATION_JSON}) @Consumes({MediaType.APPLICATION_JSON}) public interface ClientCommentService extends CrudService<ClientComment, Integer> {
/** * 查询 通知信息接口 * @param valueOf * @return */ @POST @Path("showComment") ClientComment showComment(@QueryParam("valueOf") Integer valueOf);
业务接口父类: @Consumes({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON}) public interface CrudService<T, ID> {
/** * 根据主键删除 * @param sid * @return */ @POST @Path("deleteByPrimaryKey") int deleteByPrimaryKey(@QueryParam("sid") ID sid); /** * 根据主键删除,返回删除的对象 * @param sid * @return */ @POST @Path("deleteByPrimaryKeyT") T deleteByPrimaryKeyT(@QueryParam("sid") ID sid);
....
业务接口实现类: @Service(version = "1.0.0", protocol = {"dubbo", "rest"}) @org.springframework.stereotype.Service public class ClientCommentServiceImpl extends CrudServiceImpl<ClientComment, Integer> implements ClientCommentService {
@Autowired private ClientCommentMapper clientCommentMapper; protected ClientCommentMapper getClientCommentMapper() { return getCrudMapper(); } @Override public ClientComment showComment(Integer lessonId) { // TODO Auto-generated method stub return clientCommentMapper.showComment(lessonId); }
}
补充: 通过在java代码中注入接口,使用”dubbo消费端调用dubbo服务端“,会产生以上问题。 但是通过http方式,使用"非dubbo的消费端调用dubbo的REST服务",是没有问题的。
这个当然不行 你发出到客户端的接口的范型应该指定具体类
代码如下------------------------------------
业务接口: @Path("clientCommentService") @Produces({MediaType.APPLICATION_JSON}) @Consumes({MediaType.APPLICATION_JSON}) public interface ClientCommentService extends CrudService<ClientComment, Integer> {
业务接口父类: @Consumes({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON}) public interface CrudService<T, ID> {
....
业务接口实现类: @Service(version = "1.0.0", protocol = {"dubbo", "rest"}) @org.springframework.stereotype.Service public class ClientCommentServiceImpl extends CrudServiceImpl<ClientComment, Integer> implements ClientCommentService {
}