生成Javadoc失败:ClassCastException: com.sun.tools.javadoc。ClassDocImpl不能转换为com.sun.javadoc.AnnotationTypeDoc。

时间:2022-10-15 02:44:36

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
[ERROR] import javax.inject.Named;
[ERROR] ^
[ERROR] TransactionServiceExternalImpl.java:5: cannot find symbol
[ERROR] symbol: class Named
[ERROR] @Named("transactionServiceExternal")
[ERROR] ^
[ERROR] java.lang.ClassCastException: com.sun.tools.javadoc.ClassDocImpl cannot be cast to com.sun.javadoc.AnnotationTypeDoc

[错误]退出代码:1 - .java:3:包javax。注入不存在[ERROR]导入javax.injec . named;(错误)^(错误)TransactionServiceExternalImpl。java:5:找不到符号(错误)符号:类命名为【错误】@ Named(“transactionServiceExternal”)(错误)^(错误). lang。com.sun.tools.javadoc ClassCastException。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

我得到了误差

  • jdk1.5.0_22
  • jdk1.5.0_22
  • jdk1.6.0_29
  • jdk1.6.0_29
  • jdk1.6.0_43
  • jdk1.6.0_43
  • jdk1.6.0_43_32bit
  • jdk1.6.0_43_32bit

But NOT with...

但不是用…

  • jdk1.7.0_05
  • jdk1.7.0_05

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. and this is the cause of the problem.

我现在知道了,原因是Maven Javadoc插件已经从2.9.1更改为2.10。这就是问题的原因。

I can see this warning...

我能看到这个警告…

[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-javadoc-plugin is missing. [WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-deploy-plugin is missing.

build.plugins.plugin[警告]”。为org.apache.maven版本”。插件:maven-javadoc-plugin不见了。build.plugins.plugin[警告]”。为org.apache.maven版本”。插件: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. You should be up and working again, you just need to remove this tmp version when the real release comes out.

附带说明:您可以克隆版本2.9.1的SVN repo,将pom更新为2.10.1,进行mvn安装,将其放入您的M2文件夹中。您应该重新开始工作,您只需要在真正的发行版发布时删除这个tmp版本。

6 个解决方案

#1


13  

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. The jira issue is http://jira.codehaus.org/browse/MJAVADOC-408.

我们的项目也有同样的问题。有很多人都有这个问题,所以对于maven-javadoc-plugin来说,这应该是一个问题,因为mavenjavadoc-plugin破坏了mvn版本:在第一个答案中执行声明。jira的问题是http://jira.codehaus.org/browse/MJAVADOC-408。

Temporal solutions:

临时解决方案:

  • Execute build with -Dmaven.javadoc.skip=true option
  • 与-Dmaven.javadoc执行构建。跳过= true选项
  • Add this property in pom.xml <maven.javadoc.failOnError>false</maven.javadoc.failOnError>
  • 在pom中添加此属性。xml < maven.javadoc.failOnError >假< / maven.javadoc.failOnError >
  • Fix maven-javadoc-plugin version to 2.9.1 in your pluginManagement section like
  • 在您的插件管理部分中,将maven-javadoc-plugin版本修复为2.9.1。
<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. Im not able to check it out.

更新2在评论中还说,2.10.1版本解决了这个问题。我看不出来。

#2


2  

We have the same problem and we temporarily solved this issue by explicitly specify Maven Javadoc Plugin version to 2.9.1

我们有同样的问题,我们暂时解决了这个问题,通过显式地将Maven Javadoc插件版本指定为2.9.1

#3


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.

这不是帮助。

#4


1  

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>

#5


0  

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

解决问题

#6


0  

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>

#1


13  

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. The jira issue is http://jira.codehaus.org/browse/MJAVADOC-408.

我们的项目也有同样的问题。有很多人都有这个问题,所以对于maven-javadoc-plugin来说,这应该是一个问题,因为mavenjavadoc-plugin破坏了mvn版本:在第一个答案中执行声明。jira的问题是http://jira.codehaus.org/browse/MJAVADOC-408。

Temporal solutions:

临时解决方案:

  • Execute build with -Dmaven.javadoc.skip=true option
  • 与-Dmaven.javadoc执行构建。跳过= true选项
  • Add this property in pom.xml <maven.javadoc.failOnError>false</maven.javadoc.failOnError>
  • 在pom中添加此属性。xml < maven.javadoc.failOnError >假< / maven.javadoc.failOnError >
  • Fix maven-javadoc-plugin version to 2.9.1 in your pluginManagement section like
  • 在您的插件管理部分中,将maven-javadoc-plugin版本修复为2.9.1。
<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. Im not able to check it out.

更新2在评论中还说,2.10.1版本解决了这个问题。我看不出来。

#2


2  

We have the same problem and we temporarily solved this issue by explicitly specify Maven Javadoc Plugin version to 2.9.1

我们有同样的问题,我们暂时解决了这个问题,通过显式地将Maven Javadoc插件版本指定为2.9.1

#3


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.

这不是帮助。

#4


1  

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>

#5


0  

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

解决问题

#6


0  

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>