註解的繼承性

參考鏈接:https://www.jianshu.com/p/a848655d478e

備註:帶參數的方法改如何獲取註解:

ResponseEntity queryList(Integer pageNum, Integer pageSize, Map<String, String> map);
public static void main(String[] args) {

    try {
        //類註解
        Method foo = BrandsPointsPoolResource.class.getMethod("queryList",Integer.class,Integer.class,Map.class);
        System.out.println(Arrays.toString(foo.getAnnotations()));
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    }
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章