本文主要介绍使用Java Maven maven-site plugins 3.3 插件报错(java.lang.ClassNotFoundException: org.apache.maven.doxia.siterenderer.DocumentContent 。 Error injecting: org.apache.maven.report.projectinfo.CiManagementReport java.lang.NoClassDefFoundError: org/apache/maven/doxia/siterenderer/DocumentContent)解决三种方法。

1、Pom.xml中配置maven-site-plugin

在pom.xml中专门定义maven-site-pluginmaven-project-info-reports-plugin以及版本号。

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>

2、Pom.xml指定maven-project-info-reports-plugin版本

如果上面方法没有解决,可以尝试下面方法.

由于将maven-project-info-reports-plugin更新为3.0.0,并依赖于doxia-site-renderer 1.8(并且具有org.apache.maven.doxia.siterenderer.DocumentContent此类),但是maven-site-plugin:3.3依赖于doxia-site-renderer:1.4(并且没有org.apache.maven.doxia.siterenderer.DocumentContent

指定特定的maven-project-info-reports-plugin版本:

<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.9</version>
</plugin>
</plugins>
</reporting>

或者可以将maven-site-plugin指定为最新的3.7.1,例如:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>

3、Pom.xml中配置build部分Maven网站插件的版本

<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
<reportSets>
<reportSet>
<reports>
<report>index</report>
<report>licenses</report>
<report>dependency-info</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
<build>
<plugins>
<!-- Part of Maven - specified version explicitly for compatibility
with the maven-project-info-reports-plugin 3.0.0-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
</plugins>
</build>

推荐文档