使用Enunciate生成API文档时出错

时间:2010-09-14 21:32:14

标签: soap wsdl documentation-generation enunciate

我创建了一个Web服务,并希望为API生成文档。所以我查看Enunciate下载了maven enunciate插件。但是我在编译时得到以下错误,因为webservice注释在我的POJO实现的接口类上而不是POJO本身。

I don't want to clutter the POJO by adding the annotations to it.  

    artifact org.mortbay.jetty:maven-jetty-plugin: checking for updates from central
[INFO] [enunciate:docs {execution: default}]
[INFO] initializing enunciate.
[INFO] invoking enunciate:generate step...
[WARNING] Validation result has errors.
/Users/vkumar/IdeaProjects/identity-service/trunk/src/main/java/com/foobar/ids/service/IDService.java:17: [jersey] Jersey doesn't support interfaces as root resources. 
The @Path parameter will need to be applied to the implementation class.

public interface IDService {
       ^
1 error
[INFO] ------------------------------------------------------------------------


pom.xml片段在这里

        <plugin>
          <groupId>org.codehaus.enunciate</groupId>
          <artifactId>maven-enunciate-plugin</artifactId>
          <!-- check for the latest version -->
          <version>1.20</version>
          <executions>
            <execution>
              <goals>
                <goal>docs</goal>
              </goals>
              <configuration>

                <!-- the directory where to put the docs -->
                <docsDir>${project.build}/docs </docsDir>

              </configuration>
            </execution>
          </executions>
        </plugin>

1 个答案:

答案 0 :(得分:2)

这是泽西岛的一个限制。你必须注释你的实现类。

但是,CXF没有提出相同的要求,因此您可能需要考虑使用JAX-RS的CXF实现而不是Jersey实现:

    <plugin>
      <groupId>org.codehaus.enunciate</groupId>
      <artifactId>maven-enunciate-cxf-plugin</artifactId>
      <!-- check for the latest version -->
      <version>1.20</version>
      <executions>
        <execution>
          <goals>
            <goal>docs</goal>
          </goals>
          <configuration>

            <!-- the directory where to put the docs -->
            <docsDir>${project.build}/docs </docsDir>

          </configuration>
        </execution>
      </executions>
    </plugin>