0

资源类定义如下:

@Path("v1")
@Produces({MediaType.APPLICATION_JSON})
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public class RestApi {

我有一个这样定义的方法:

@GET
@Path("patients")
public String patients(

当我运行 maven 命令运行enunciate doc 目标时,生成的 wadl 如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<wadl:application xmlns:wadl="http://wadl.dev.java.net/2009/02" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <wadl:doc xmlns:enunciate="http://enunciate.codehaus.org/" enunciate:generatedBy="Enunciate-1.27"/>
  <wadl:grammars>
    <wadl:include href="ns0.xsd"/>
  </wadl:grammars>
  <wadl:resources base="http://localhost:8888/app/api">
...
    <wadl:resource path="/rest/v1/patients">
      <wadl:method name="GET">

这个“/rest/”在资源路径中来自哪里?我在我的项目中到处搜索,没有任何参考。

这是我的 enunciate.xml 配置文件:

<enunciate label="Rest API"
           xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.28.xsd"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <deployment host="localhost:8888" context="/app/api"/>

</enunciate>
4

1 回答 1

2

显然“/rest”只是一个默认值。您可以通过将其添加到您的 enunciate.xml 文件来将其更改为空:

<services>
     <rest defaultRestSubcontext="/" />
</services>
于 2014-02-08T00:57:51.520 回答