天天看点

[求助]反射和泛型的使用疑惑

接口:

public interface BaseService<T, PK extends Serializable> {
    boolean save(T record);
}      

 接口:

public interface InfoService extends BaseService<Info, Long>{
    boolean save(Info record);
}      

 实现类:

@Service("informationService")
public class InfoServiceImpl implements InfoService {
  boolean save(Info record) {
    ...
  }
}      

在使用反射调用接口infoService的save(record)时,提示save(Info ...)不存在。

根据this.getClass().getMethods()获取的方法数组中,确实不存在save(Info ...),而仅仅存在save(Object ...)。

为了不在每个模块的Service中都定义一遍BaseService中的共有接口,有什么解决方案?

求帮助~~~

作者:

Candyメ奶糖

出处:

http://www.cnblogs.com/Candies/

本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

博文来源广泛,如原作者认为我侵犯知识产权,请尽快给我发邮件

[email protected]

联系,我将以第一时间删除相关内容。