Ошибка при создании документов API с использованием Enunciate - PullRequest
0 голосов
/ 15 сентября 2010

Я создал веб-сервис и хотел бы создать документацию для API.Поэтому я посмотрел в Enunciate скачал плагин maven enunciate.Однако я получаю приведенную ниже ошибку при компиляции, так как аннотации веб-сервиса находятся на моем интерфейсном классе, который реализует мой 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 Ответ

2 голосов
/ 15 сентября 2010

Это ограничение Джерси.Вы должны аннотировать свой класс реализации.

CXF, однако, не предъявляет того же требования, поэтому вы можете рассмотреть возможность использования реализации JAX-RS в CXF вместо реализации в Джерси:

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