使用以下方法可以获取项目内全部接口,方便进行整理
@Autowired
public RequestMappingHandlerMapping requestMappingHandlerMapping;
@RequestMapping("/endpoints")
public @ResponseBody
Object showEndpointsAction() throws SQLException
{
return requestMappingHandlerMapping.getHandlerMethods().keySet().stream().map(t ->
(t.getMethodsCondition().getMethods().size() == 0 ? "GET" : t.getMethodsCondition().getMethods().toArray()[0]) + " " +
t.getPatternsCondition().getPatterns().toArray()[0]
).toArray();
}