我正在努力做一些我认为非常简单的事情——为一组已经存在的REST服务生成留档,这些服务基本上只是带有JAX-RS注释的POJO注释。我使用泽西作为实现提供者。REST API被部署为Spring Web应用程序的一部分。
我想只生成REST服务POJO的留档,所以我的enunciate.xml配置是这样的:
<?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>
我已经按照发音文档中的建议配置了我的pom.xml:
<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>
<configFile>enunciate.xml</configFile>
</configuration>
</plugin>
...
</build>
但是当我运行 mvn enunciate:docs
时,我收到以下构建错误:
[ERROR] Failed to execute goal org.codehaus.enunciate:maven-enunciate-plugin:1.25:docs (default-cli) on project NovaGlobalSSOAPI: Problem assembling the enunciate app. invalid LOC header (bad signature) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.enunciate:maven-enunciate-plugin:1.25:docs (default-cli) on project NovaGlobalSSOAPI: Problem assembling the enunciate app.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: Problem assembling the enunciate app.
at org.codehaus.enunciate.DocsMojo.execute(DocsMojo.java:99)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
Caused by: java.util.zip.ZipException: invalid LOC header (bad signature)
at java.util.zip.ZipFile.read(Native Method)
at java.util.zip.ZipFile.access$1200(ZipFile.java:31)
at java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:459)
at java.util.zip.ZipFile$1.fill(ZipFile.java:242)
at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:141)
at java.io.DataInputStream.readFully(DataInputStream.java:178)
at java.util.jar.JarFile.getBytes(JarFile.java:362)
at java.util.jar.JarFile.getManifestFromReference(JarFile.java:161)
at java.util.jar.JarFile.getManifest(JarFile.java:148)
at org.codehaus.enunciate.main.Enunciate.scanClasspath(Enunciate.java:409)
at org.codehaus.enunciate.main.Enunciate.doGenerate(Enunciate.java:319)
at org.codehaus.enunciate.ConfigMojo$MavenSpecificEnunciate.doGenerate(ConfigMojo.java:634)
at org.codehaus.enunciate.main.Enunciate$Stepper.step(Enunciate.java:1706)
at org.codehaus.enunciate.main.Enunciate$Stepper.stepTo(Enunciate.java:1738)
at org.codehaus.enunciate.DocsMojo.execute(DocsMojo.java:95)
... 21 more
我不知道,我做错了什么。有什么想法吗?
在您的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>
具有以下属性:
<properties><enunciate.version>2.10.1</enunciate.version></properties>
在您的 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>
如果您配置文档目录,会发生这种情况吗?
<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>
编辑:忘记关闭docsDir
我正在开发一个REST Web服务,其中我使用URL中的ID来指定患者,如下所示: <代码>WS/服务/患者/1 其中“1”是患者的id。所以,在代码中,我这样指定: 我在一个例子中看到了它,但是我的失败了。我得到了这个错误: 通用域名格式。太阳运动衫应用程序编程接口。容器ContainerException:方法,public void PresentationLayer。PatientReso
Enunciate目前没有gradle插件(https://jira.codehaus.org/browse/ENUNCIATE-815). 有没有办法手动触发Gradle的文档构建?
我试图使用Swagger2生成Spring-boot应用程序的REST API文档。 下面是我的application.properties文件内容: 有人能帮我弄清楚这件事吗? 提前谢谢你。
现在我们即将从昂首阔步转向SpringRest文档。 问:有没有一种方法可以像Swagger那样从Spring rest文档生成java rest客户机? 如果是-怎么做? 如果没有-是否有其他方法来获取/生成REST API客户端。
我正在尝试使用JAX-RS(Jersey)构建JSON RESTful Webservice。我也在使用Maven构建应用程序。 我的第一个方法是 pom之后。xml- 所以我补充道 到我的pom文件。其他lib文件(例如jackson-cors-asl-1.7.1.jar、jackson-jaxrs-1.7.1.jar、jaxb impl,…)也可以在生成的war文件中找到//编辑:它还下载st
我谷歌了一下,但是所有关于昂首阔步留档的例子都使用了类。我想包括接口,因为读者感兴趣的是API而不是实现。 这是我的密码: 包括所需的maven依赖项: 我的SpringBoot应用程序: 我的RestController接口 和实施 这一切都由所需的昂首阔步配置支持: 该代码可作为maven项目在https://github.com/MKhotele/spring-examples/tree/m