【发布时间】:2014-01-28 23:50:15
【问题描述】:
我已将我的 REST/Spring/Jersey 项目配置为使用 enunciate 生成 API 文档。
我的 pom.xml 中的相关变化是
<plugin>
<groupId>org.codehaus.enunciate</groupId>
<artifactId>maven-enunciate-spring-plugin</artifactId>
<version>1.28</version>
<configuration>
<generateDir>${project.build.directory}/enunciate-generate</generateDir>
<configFile>enunciate.xml</configFile>
<exports>
<jaxws.client.library.binaries>client.jar</jaxws.client.library.binaries>
</exports>
</configuration>
<executions>
<execution>
<goals>
<goal>assemble</goal>
</goals>
</execution>
</executions>
</plugin>
.....
<dependency>
<groupId>org.codehaus.enunciate</groupId>
<artifactId>maven-enunciate-spring-plugin</artifactId>
<version>1.28</version>
</dependency>
我的enunciate.xml如下
<?xml version="1.0"?>
<enunciate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.28.xsd">
<api-classes>
<include pattern="com.xxx.rest.*"/>
</api-classes>
<modules>
<docs docsDir="api" title="REST WebServices API"/>
<spring-app>
<war mergeWebXML="war/WEB-INF/web.xml"/>
<springImport file="war/WEB-INF/applicationContext-jdbc.xml"/>
</spring-app>
</modules>
</enunciate>
当我运行我的 maven 项目时,初始化发音时出现以下错误。如您所见,该错误不是很有帮助。任何提示我的配置可能有什么问题。
--- maven-enunciate-spring-plugin:1.28:assemble (默认) @ xxx --- 初始化发音。 [csharp] 禁用 C# 编译,但仍会生成源代码。
调用发音:生成步骤...
构建失败
总时间:3.324s
无法在项目 xxx 上执行目标 org.codehaus.enunciate:maven-enunciate-spring-plugin:1.28:assemble(默认):组装 enunciate 应用程序时出现问题。字符串索引超出范围:0 -> [帮助 1]
要查看错误的完整堆栈跟踪,请使用 -e 开关重新运行 Maven。 使用 -X 开关重新运行 Maven 以启用完整的调试日志记录。
有关错误和可能的解决方案的更多信息,请阅读以下文章: [求助1]http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
【问题讨论】:
-
使用
-e运行命令时会发生什么? -
@tieTYT 这是我的 -e 输出:原因:java.lang.StringIndexOutOfBoundsException:字符串索引超出范围:org.java.lang.String.charAt(String.java:658) 处的 0。 codehaus.enunciate.main.ImportedClassesClasspathHandler.handleResource(ImportedClassesClasspathHandler.java:55) at org.codehaus.enunciate.main.Enunciate.scanClasspath(Enunciate.java:457) at org.codehaus.enunciate.main.Enunciate.doGenerate(Enunciate. java:350)
-
java.lang.String.charAt(String.java:658) rg.codehaus.enunciate.main.ImportedClassesClasspathHandler.handleResource(ImportedClassesClasspathHandler.java:55org.codehaus.enunciate.main.Enunciate.scanClasspath( Enunciate.java:462)atg.codehaus.enunciate.main.Enunciate.doGenerate(Enunciate.java:355)atrg.codehaus.enunciate.ConfigMojo$MavenSpecificEnunciate.doGenerate(ConfigMojo.java:670)atrg.codehaus.enunciate.main。 Enunciate$Stepper.step(Enunciate.java:1799)atrg.codehaus.enunciate.main.Enunciate$Stepper.stepTo(Enunciate.java:1831)atrg.codehaus.enunciate.AssembleMojo.execute(AssembleMojo.java:71)。
-
经过一番调查后发现我的 pom.xml 中有一些招摇的依赖,这导致 enunciate 抛出上述错误。我删除了 swagger 依赖项,现在我能够克服上述错误。但是,我现在收到此错误。无法在项目 dcat-rest 上执行目标 org.codehaus.enunciate:maven-enunciate-spring-plugin:1.28:assemble (default):组装 enunciate 应用程序时出现问题。 APT 调用失败。请参阅jira.codehaus.org/browse/ENUNCIATE-771 以了解已出现这种情况的情况。没有对此错误的解释。 -> [帮助1].....调查中