2010-09-14 2 views
0

J'ai créé un service Web et souhaite générer une documentation pour l'API. J'ai donc regardé dans Enunciate téléchargé le plugin enunciate maven. Cependant, je reçois l'erreur ci-dessous lors de la compilation car les annotations de service web sont sur ma classe d'interface que mon POJO implémente plutôt que le POJO lui-même.Erreur lors de la génération de documents API à l'aide d'Enunciate

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


L'extrait pom.xml est ici

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

Répondre

2

C'est une limitation de Jersey. Vous devez annoter votre classe d'implémentation.

CXF, cependant, ne fait pas la même exigence, vous voudrez peut-être envisager d'utiliser la mise en œuvre CXF de JAX-RS au lieu de la mise en œuvre 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> 
Questions connexes