Java 阐明:在我的wadl中,为什么我的所有资源路径属性都以“路径”作为前缀/“休息”吗;?

Java 阐明:在我的wadl中,为什么我的所有资源路径属性都以“路径”作为前缀/“休息”吗;?,java,rest,maven,enunciate,jersey-1.0,Java,Rest,Maven,Enunciate,Jersey 1.0,资源类的定义如下: @Path("v1") @Produces({MediaType.APPLICATION_JSON}) @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public class RestApi { @GET @Path("patients") public String patients( <?xml version="1.0" encoding="UTF-8"?> <

资源类的定义如下:

@Path("v1")
@Produces({MediaType.APPLICATION_JSON})
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public class RestApi {
@GET
@Path("patients")
public String patients(
<?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">
我有一个定义如下的方法:

@Path("v1")
@Produces({MediaType.APPLICATION_JSON})
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public class RestApi {
@GET
@Path("patients")
public String patients(
<?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">
当我运行maven命令来运行doc目标时,生成的wadl如下所示:

@Path("v1")
@Produces({MediaType.APPLICATION_JSON})
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public class RestApi {
@GET
@Path("patients")
public String patients(
<?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/”来自何处?我在我的项目中到处都找过了,没有任何参考资料

下面是我的enounciate.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>

显然“/rest”只是一个默认值。通过将以下内容添加到您的eNucliate.xml文件中,可以将其更改为nothing:

<services>
     <rest defaultRestSubcontext="/" />
</services>