0

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

我不想通过向 POJO 添加注释来弄乱 POJO。  

    工件 org.mortbay.jetty:maven-jetty-plugin:检查来自中央的更新
[信息] [阐明:文档{执行:默认}]
[INFO] 初始化发音。
[INFO] 调用发音:生成步骤...
[警告] 验证结果有错误。
/Users/vkumar/IdeaProjects/identity-service/trunk/src/main/java/com/foobar/ids/service/IDService.java:17:[jersey] Jersey 不支持将接口作为根资源。
@Path 参数需要应用于实现类。

公共接口 IDService {
       ^
1 个错误
[信息] --------------------------------------------- -------------------------


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>
4

1 回答 1

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>
于 2010-09-15T14:47:08.750 回答