使用 Enunciate 生成 API 文档时出错
我创建了一个 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>
I created a webservice and would like to generate documentation for the API. So I looked into Enunciate downloaded the maven enunciate plugin. However I get the below error on compile as the webservice annotations are on my interface class that my POJO implements rather than the POJO itself.
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] ------------------------------------------------------------------------
The pom.xml snippet is here
<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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是泽西岛的限制。您必须注释您的实现类。
然而,CXF 没有提出相同的要求,因此您可能需要考虑使用 JAX-RS 的 CXF 实现而不是 Jersey 实现:
That's a limitation of Jersey. You have to annotate your implementation class.
CXF, however, doesn't make that same requirement, so you may want to consider using the CXF implementation of JAX-RS instead of the Jersey implementation: