[英]Javadoc generation failed : ClassCastException: com.sun.tools.javadoc.ClassDocImpl cannot be cast to com.sun.javadoc.AnnotationTypeDoc
I'm getting the following error when I do 我这样做时会出现以下错误
mvn clean deploy -DperformRelease=true
[ERROR] Exit code: 1 - .java:3: package javax.inject does not exist
[错误]退出代码:1 - .java:3:包javax.inject不存在
[ERROR] import javax.inject.Named;[错误]导入javax.inject.Named;
[ERROR] ^[错误] ^
[ERROR] TransactionServiceExternalImpl.java:5: cannot find symbol[ERROR] TransactionServiceExternalImpl.java:5:找不到符号
[ERROR] symbol: class Named[错误]符号:类命名
[ERROR] @Named("transactionServiceExternal")[错误] @Named(“transactionServiceExternal”)
[ERROR] ^[错误] ^
[ERROR] java.lang.ClassCastException: com.sun.tools.javadoc.ClassDocImpl cannot be cast to com.sun.javadoc.AnnotationTypeDoc[错误] java.lang.ClassCastException:com.sun.tools.javadoc.ClassDocImpl无法强制转换为com.sun.javadoc.AnnotationTypeDoc
The POM is this... POM就是这个......
<groupId>com.xxx</groupId>
<artifactId>ts-impl/artifactId>
<version>2.4.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
</dependencies>
There is only one class... 只有一节课......
import javax.inject.Named;
@Named("transactionServiceExternal")
public class TransactionServiceExternalImpl
{
}
I get the error with 我得到了错误
But NOT with... 但不是......
Anyone have any ideas? 有人有想法么?
Notes: Apache Maven 3.0.4 (r1232337; 2012-01-17 08:44:56+0000) 备注:Apache Maven 3.0.4(r1232337; 2012-01-17 08:44:56 + 0000)
I now know that the reason is that the Maven Javadoc Plugin has changed from 2.9.1 to 2.10. 我现在知道原因是Maven Javadoc插件已经从2.9.1变为2.10。 and this is the cause of the problem.
这就是问题的原因。
I can see this warning... 我可以看到这个警告......
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-javadoc-plugin is missing. [警告] org.apache.maven.plugins的'build.plugins.plugin.version':缺少maven-javadoc-plugin。 [WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-deploy-plugin is missing.
[警告] org.apache.maven.plugins的'build.plugins.plugin.version':缺少maven-deploy-plugin。
By setting the following in my pom.... 通过在我的pom中设置以下内容....
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
I can fix the version back to the last release. 我可以将版本修复回上一版本。
I will raise a bug with the Maven Javadoc creators. 我将向Maven Javadoc创建者提出一个错误。
http://jira.codehaus.org/browse/MJAVADOC-407 http://jira.codehaus.org/browse/MJAVADOC-407
On a side note: you can clone the SVN repo for version 2.9.1, update the pom to 2.10.1, do a mvn install to put it in you M2 folder. 请注意:您可以克隆版本2.9.1的SVN repo,将pom更新为2.10.1,执行mvn安装将其放入您的M2文件夹中。 You should be up and working again, you just need to remove this tmp version when the real release comes out.
你应该重新开始工作,只需要在真正发布时删除这个tmp版本。
Were having same problems in our projects. 在我们的项目中遇到同样的问题。 Theres a lot of people having this problem so should be a issue regarding maven-javadoc-plugin as maven-javadoc-plugin breaks mvn release:perform stated in first answer.
很多人都有这个问题所以应该是关于maven-javadoc-plugin的问题,因为maven-javadoc-plugin打破了mvn release:在第一个答案中说明了。 The jira issue is http://jira.codehaus.org/browse/MJAVADOC-408 .
jira问题是http://jira.codehaus.org/browse/MJAVADOC-408 。
Temporal solutions: 时间解决方案:
-Dmaven.javadoc.skip=true
option -Dmaven.javadoc.skip=true
选项执行构建 <maven.javadoc.failOnError>false</maven.javadoc.failOnError>
<maven.javadoc.failOnError>false</maven.javadoc.failOnError>
<pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <version>2.9.1</version> </plugin> </plugins> </pluginManagement>
I hope issue is fixed soon. 我希望问题很快得到解决。
Update According to Noremac in comments, if you are using release plugin and want to pass arguments to it, the right way to do it is -Darguments="-Dmaven.javadoc.skip=true". 更新根据Noremac的评论,如果您正在使用发布插件并希望将参数传递给它,正确的方法是-Darguments =“ - Dmaven.javadoc.skip = true”。
Ill keep the other way in my answer, because this is happening in any maven build that is using javadoc. 在我的回答中保持另一种方式,因为这发生在使用javadoc的任何maven构建中。
Update 2 Also TheConstructor in comments says that 2.10.1 version fix the problem. 更新2此外,评论中的TheConstructor说2.10.1版本修复了这个问题。 Im not able to check it out.
我无法检查出来。
我们遇到了同样的问题,我们通过明确地将Maven Javadoc插件版本指定为2.9.1来暂时解决了这个问题
From jira http://jira.codehaus.org/browse/MJAVADOC-407 : 来自jira http://jira.codehaus.org/browse/MJAVADOC-407 :
build classes (including 3rd-parties dependencies) are not on javadoc classpath anymore
构建类(包括第三方依赖项)不再位于javadoc类路径上
But if I add dependecies to maven-javadoc-plugin: 但是,如果我将依赖添加到maven-javadoc-plugin:
...
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10</version>
<dependencies>
<dependency>
<groupId>org.apache.cayenne</groupId>
<artifactId>cayenne-server</artifactId>
<version>3.1B2</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
</build>
...
this not help. 这没有用。
This somewhat worked for me, I had to add the plugin this way since we already had other plugins set for builds. 这有点对我有用,我必须以这种方式添加插件,因为我们已经为构建设置了其他插件。 Note I removed our other plugins from the example below:
注意我从以下示例中删除了我们的其他插件:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
</plugin>
</plugins>
</build>
add this to parent pom: 将此添加到父pom:
<build>
...
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
</plugin>
</plugins>
</pluginManagement>
...
<build>
solve problem 解决问题
Use following plugin to generate java docs. 使用以下插件生成java文档。
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.