2

我正在为现有的 Java REST(使用 Jersey)项目使用“发音”。我有 build.xml 和 enunciate.xml:创建了输出文件 docs.zip,但解压缩此文件后,我有:css/ dir、js/ dir、robots.txt、model.html、index.html、favicon.ico、 crossdomain.xml、application.wadl、apple-touch-icon.png 文件。

index.html 和 model.html 没有来自我的 java REST 代码的任何文档。有人可以在这里帮助我吗?我没有“口齿伶俐”的经验。

谢谢,

---> 这是 REST 代码示例之一:

@Path("/{spacecraftId}/log")

公共类 UserLogHandler 实现 ProcessCommunicationFacilityFailureListenerInterface,MessageCustomerInterface,IMessageAvailable {

/**
 *  Retrieve log file information from MySQL database:
 *
 */
@GET
@Produces(MediaType.TEXT_XML)
public Response retrieveLogFromDatabase(
        @PathParam("spacecraftId") String spacecraftId,
        @Context HttpServletRequest servletRequest)
{
}

}

---> 'build.xml' 文件:

<!--The enunciate classpath points to all the jars in the "lib" directory.-->
<path id="enunciate.classpath">

 <pathelement path="${acmd-class-dir}:${mdasclasses.dir}"/>

  <fileset dir="/TPS/V19.0.2">
    <include name="xerces/xercesImpl.jar"/>
    <include name="xerces/xml-apis.jar"/>
    <include name="jdkaddons/jdom.jar"/>
    <include name="jdkaddons/mail.jar"/>
    <include name="jdkaddons/commons-codec.jar"/>
    <include name="jdkaddons/asm-3.1.jar"/>
    <include name="jdkaddons/jersey-core-1.7.jar"/>
    <include name="jdkaddons/jersey-server-1.7.jar"/>
    <include name="jdkaddons/jsr311-api-1.1.1.jar"/>
    <include name="jdkaddons/jersey-client-1.7.jar"/>
    <include name="jdkaddons/jersey-multipart-1.7.jar"/>
  </fileset>


  <fileset dir="${enunciate.home}/lib">
    <include name="*.jar"/>
  </fileset>

  <fileset dir="${enunciate.java}"> 
    <include name="lib/tools.jar"/>
  </fileset>           

</path>

<!--define the task...-->
<taskdef name="enunciate" classname="org.codehaus.enunciate.main.EnunciateTask">
  <classpath refid="enunciate.classpath"/>
</taskdef>

<enunciate basedir="./" verbose="true" configFile="./enunciate.xml" >

  <include name="**/*.java"/>
  <classpath refid="enunciate.classpath"/>
  <export artifactId="docs" destination="./docs.zip"/>  
  <javacArgument argument="-g"/> 
</enunciate>

---> 'enunciate.xml' 文件:

<api-classes>
    <include pattern="/tps/tomcat/lib/servlet-api.jar"/>>

    <exclude pattern="com.sun.jersey.multipart.FormDataParam"/>
</api-classes>

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

<webapp disabled="true">
</webapp>

<modules>
  <disable-rule id="csharp.warnings"/>
  <disable-rule id="c-warnings"/>
  <disable-rule id="obj-c.warnings"/>
  <basic-app disabled="true"/>
  <c disabled="true"/>
  <csharp disabled="true"/>
  <jaxws-ri disabled="true"/>
  <obj-c disabled="true"/>
  <amf disabled="true"/>
  <gwt disabled="true"/>
  <jboss disabled="true"/>
  <object-c disabled="true"/>
  <rubby disabled="true"/>
  <jaxws-client disabled="true"/>

  <jersey disabled="false"/>

  <docs title="ICMD API"  docsDir="./" splashPackage="cmd.acmd_mdc_servlet" includeDefaultDownloads="true" includeExampleXml="false" disableRestMountpoint="true" copyright="copyright" forceExampleJson="true"/>
</modules>

4

1 回答 1

2

您的“包含模式”不正确。“包含”是指classes,而不是jars。所以它可能看起来像:

 <include pattern="com.mycompany.api.resources.**"/>

此外,当您调用 Enunciate 时,请确保所有这些类都在您的类路径中。

于 2013-12-05T00:47:03.157 回答