2014-04-29 8 views
0

내 휴식 API 문서를 생성하려면 enunciate를 사용하고 있습니다. 프로젝트에 스프링 의존성을 추가하지 않으면 처음에는 정상적으로 작동했습니다.
나의 현재 POM : 구성 위브라우저에 배포 된 전쟁에서 생성 된 문서를 enunciate에 액세스 할 수 없습니다.

<dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-context</artifactId> 
     <version>3.2.5.RELEASE</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-core</artifactId> 
     <version>3.2.5.RELEASE</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-beans</artifactId> 
     <version>3.2.5.RELEASE</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-webmvc</artifactId> 
     <version>3.2.5.RELEASE</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.data</groupId> 
     <artifactId>spring-data-rest-webmvc</artifactId> 
     <version>2.0.2.RELEASE</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.data</groupId> 
     <artifactId>spring-data-neo4j</artifactId> 
     <version>3.0.1.RELEASE</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.data</groupId> 
     <artifactId>spring-data-neo4j-rest</artifactId> 
     <version>3.0.1.RELEASE</version> 
    </dependency> 
      <dependency> 
     <groupId>javax.validation</groupId> 
     <artifactId>validation-api</artifactId> 
     <version>1.0.0.GA</version> 
    </dependency> 
    <dependency> 
     <groupId>com.sun.jersey</groupId> 
     <artifactId>jersey-server</artifactId> 
     <version>1.18.1</version> 
    </dependency> 
    <dependency> 
     <groupId>com.sun.jersey</groupId> 
     <artifactId>jersey-servlet</artifactId> 
     <version>1.18.1</version> 
    </dependency> 
    <dependency> 
     <groupId>org.codehaus.enunciate</groupId> 
     <artifactId>enunciate-rt</artifactId> 
     <version>1.26</version> 
    </dependency> 
</dependencies> 

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-war-plugin</artifactId> 
      <version>2.2</version> 
      <configuration> 
       <webResources> 
        <resource> 
         <directory>src/main/webapp</directory> 
         <filtering>true</filtering> 
         <includes> 
          <include>index.html</include> 
         </includes> 
        </resource> 
       </webResources> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.codehaus.enunciate</groupId> 
      <artifactId>maven-enunciate-plugin</artifactId> 
      <version>1.26</version> 
      <configuration> 
       <configFile>src/main/resources/enunciate.xml</configFile> 
      </configuration> 
      <executions> 
       <execution> 
        <goals> 
         <goal>assemble</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
    <pluginManagement> 
     <plugins> 
      <plugin> 
       <groupId>org.eclipse.m2e</groupId> 
       <artifactId>lifecycle-mapping</artifactId> 
       <version>1.0.0</version> 
       <configuration> 
        <lifecycleMappingMetadata> 
         <pluginExecutions> 
          <pluginExecution> 
           <pluginExecutionFilter> 
            <groupId>org.codehaus.enunciate</groupId> 
            <artifactId>maven-enunciate-plugin</artifactId> 
            <versionRange>[1.26,)</versionRange> 
            <goals> 
             <goal>assemble</goal> 
            </goals> 
           </pluginExecutionFilter> 
           <action> 
            <ignore></ignore> 
           </action> 
          </pluginExecution> 
         </pluginExecutions> 
        </lifecycleMappingMetadata> 
       </configuration> 
      </plugin> 
     </plugins> 
    </pluginManagement> 
</build> 

전쟁에서 api 디렉토리에 문서를 생성하고 생성입니다. 나는 enunciate.xml에게 구성은 다음과 같습니다

<enunciate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.26.xsd"> 
<webapp mergeWebXML="../webapp/WEB-INF/web.xml"></webapp> 
<modules> 
    <docs splashPackage="com.pack.resources" docsDir="api" title="My API" copyright="amg" includeDefaultDownloads="true" /> 
    <jersey useSubcontext="true" /> 
</modules> 

문서가 제대로 생성됩니다,하지만 때는 404 응답을 제공 http://localhost:8080/amg-web/api/index.html를 공격하려합니다.! 나는 모든 필수 파일과 함께 api 디렉토리가 성공적으로 생성되었지만 여전히 브라우저의 배포 된 응용 프로그램에서 액세스 할 수없는 tomcat webapp에서 추출한 전쟁을 조사했습니다. 도와주세요.

답변

0

해결책을 찾은 것 같습니다. 이전 버전의 enunciate, 즉 v1.26을 사용 중이거나 <url-pattern>이 여러 번 있습니다. web.xml에 있습니다.
나는 추가 servlet mapping을 추가하고 일했다 ..

<servlet-mapping> 
    <servlet-name>default</servlet-name> 
    <url-pattern>/api/*</url-pattern> 
</servlet-mapping> 

/api/ 내 API 문서에 대한 경로입니다. 나는 아직도 왜 이것이 필요한지를 알지 못했다. 누군가가 나에게 이것을 설명하면 좋을 것이다.