如何为SpringJersey项目生成带有Enouncate的REST文档?
我正在努力做一些我认为非常简单的事情——为一组已经存在的REST服务生成文档,这些服务基本上只是带有JAX-RS注释的POJO注释。我正在使用Jersey作为实现提供者。RESTAPI作为Springweb应用程序的一部分进行部署 我只想为REST服务POJO生成文档,因此我的enuciate.xml配置如下:如何为SpringJersey项目生成带有Enouncate的REST文档?,spring,maven,jersey,enunciate,Spring,Maven,Jersey,Enunciate,我正在努力做一些我认为非常简单的事情——为一组已经存在的REST服务生成文档,这些服务基本上只是带有JAX-RS注释的POJO注释。我正在使用Jersey作为实现提供者。RESTAPI作为Springweb应用程序的一部分进行部署 我只想为REST服务POJO生成文档,因此我的enuciate.xml配置如下: <?xml version="1.0"?> <enunciate label="novaglobalapi" xmlns:xsi="http://www.w3.org/
<?xml version="1.0"?>
<enunciate label="novaglobalapi" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.25.xsd">
<api-classes>
<include pattern="com.something.api.rest.*"/>
</api-classes>
<modules>
<docs docsDir="restapi" title="REST API"/>
</modules>
</enunciate>
我不明白,我做错了什么。有什么想法吗?如果配置文档目录,会发生这种情况吗
<build>
...
<plugin>
<groupId>org.codehaus.enunciate</groupId>
<artifactId>maven-enunciate-plugin</artifactId>
<version>1.25</version>
<executions>
<execution>
<goals>
<goal>docs</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- the directory where to put the docs -->
<docsDir>${project.build.directory}/docs</docsDir>
<configFile>enunciate.xml</configFile>
</configuration>
</plugin>
...
</build>
...
org.codehaus.expunciate
maven发音插件
1.25
文件
${project.build.directory}/docs
expensiate.xml
...
编辑:忘记关闭docsDir在maven pom中使用以下代码:
<build>
<plugins>
<plugin>
<groupId>com.webcohesion.enunciate</groupId>
<artifactId>enunciate-maven-plugin</artifactId>
<version>${enunciate.version}</version>
<configuration>
<sourcepath-includes>
<sourcepath-include>
<groupId>com.your.company.web.rest</groupId>
</sourcepath-include>
<sourcepath-include>
<groupId>com.external</groupId>
<artifactId>external</artifactId>
</sourcepath-include>
</sourcepath-includes>
</configuration>
<executions>
<execution>
<goals>
<goal>assemble</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
阐明
阐明maven插件
${enuciate.version}
com.your.company.web.rest
com.external
外部的
集合
具有以下属性:
<properties><enunciate.version>2.10.1</enunciate.version></properties>
2.10.1
在maven主页中,请确保有一个名为enunciate.xml的xml文件,其中包含以下代码行:
<enunciate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://enunciate.webcohesion.com/schemas/enunciate-2.0.0-M.4.xsd">
<title>Your Company REST API</title>
<description package="com.your.company.web.api"/>
<copyright>www.yourcompany.com</copyright>
<api-classes>
<include pattern="com.your.company.web.rest.*"/>
</api-classes>
<modules>
<docs docsDir="src/main/webapp/restapi" title="Your Company REST API"/>
<jackson disabled="true"/>
<swagger basePath="/yourcompany/api/"/>
</modules>
</enunciate>
贵公司的RESTAPI
www.yourcompany.com
是。即使我将绝对路径设置为docs
-目录,也会发生相同的错误。你能建议我做更多的尝试或者一些故障排除步骤吗?我真的很感激。你不会相信实际的错误是什么。我是在另一个项目中发现的,该项目也使用相同的Jersey依赖项。我得到了同样的坏LOC
-例外。这不是巧合,我想我是对的。显然,Maven下载的jersey jar已经损坏。所以,这不是一个明确的特定错误。移除损坏的罐子并得到一个新的似乎让我感到兴奋。无论如何谢谢你!
<properties><enunciate.version>2.10.1</enunciate.version></properties>
<enunciate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://enunciate.webcohesion.com/schemas/enunciate-2.0.0-M.4.xsd">
<title>Your Company REST API</title>
<description package="com.your.company.web.api"/>
<copyright>www.yourcompany.com</copyright>
<api-classes>
<include pattern="com.your.company.web.rest.*"/>
</api-classes>
<modules>
<docs docsDir="src/main/webapp/restapi" title="Your Company REST API"/>
<jackson disabled="true"/>
<swagger basePath="/yourcompany/api/"/>
</modules>
</enunciate>