2013-03-22 47 views
3

我有一个应用程序使用Spring注释和Spring MVC公开REST风格的动作。列出Spring动作的可用路径

它看起来像

@RequestMapping(value = "/example/{someId}", 
    method = RequestMethod.GET, consumes=MediaType.APPLICATION_JSON_VALUE, 
    produces=MediaType.APPLICATION_JSON_VALUE) 
@ResponseBody 
public void isRegisteredToThread(@PathVariable long someId, HttpServletResponse response) { 

    [something] 
} 

我要的是所有的URL,方法和可用参数的自动生成清单 - 可能是内部的WSDL。有插件还是有些可用?

+2

看看[这个答案](http://stackoverflow.com/a/9767985/750510)。我认为这可能对你有所帮助。 – madhead 2013-03-23 01:19:36

回答

0

WSDL没有完成休息,它用于SOAP。

您可以使用WADL,但我真的不建议它。

在我的项目,我总是用招摇(有一个释放的弹簧)。您可能在这里找到更多信息https://github.com/martypitt/swagger-springmvc和这里http://blog.zenika.com/index.php?post/2013/07/11/Documenting-a-REST-API-with-Swagger-and-Spring-MVC

试试看。

作为替代方案,如果你不需要的东西基于网络的,您可以尝试其他壳(https://github.com/spring-projects/rest-shell

0

你可以看看由Spring启动提供RequestMappingEndpoint的源代码,看看Spring Boot如何报告映射。

寻找通过代码可以看到的映射(包括处理程序和方法映射)能够容易地从的applicationContext获得

(使用

applicationContext.getBeansOfType(AbstractUrlHandlerMapping.class) 

applicationContext.getBeansOfType(AbstractHandlerMethodMapping.class) 

分别)。在获得映射后,您可以随意处理它们。 您可能想创建一个库,可以包含在所有项目中处理您的组织所需的映射