參考鏈接: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(); } }