Java 无法在浏览器中从已部署的war访问“阐明”生成的文档
我正在使用Enounceate生成rest api文档,最初它运行良好,除非我将spring依赖项添加到我的项目中。Java 无法在浏览器中从已部署的war访问“阐明”生成的文档,java,spring,enunciate,Java,Spring,Enunciate,我正在使用Enounceate生成rest api文档,最初它运行良好,除非我将spring依赖项添加到我的项目中。 我目前的pom: <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>3.2.5.RELEASE</ver
我目前的pom:
<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>
文档正确生成,但当我尝试点击
http://localhost:8080/amg-web/api/index.html
它给出了404响应。!我在tomcat webapp中检查了提取的war,其中成功生成了包含所有必需文件的api
目录,但仍然无法从浏览器中部署的应用访问它。请帮忙。我想我找到了解决办法。它可能与我正在使用的Enouncate的旧版本(即v1.26)有关,或者在我的web.xml中有多个
我添加了额外的servlet映射
,它成功了
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
违约
/原料药/*
其中/api/
是指向我的api文档的路径。我仍然不明白为什么有必要这样做。如果有人能给我解释一下,那就太好了
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>