Java 8 配置Maven-javadoc-plugin

阅读更多

在升级JDK至1.8之后,使用Maven-javadoc-plugin插件打包报错,[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.10.4:jar (attach-javadocs) on project 详细信息如下

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.10.4:jar (attach-javadocs) on project StatisticsReport: MavenReportException: Error while generating Javadoc:
[ERROR] Exit code: 1 - D:\Multi-module-project\StatisticsReport\src\main\java\com\yuewen\statistics\report\service\db\PullData.java:29: 警告: @param 没有说明
[ERROR] @param preparedStatement
[ERROR] ^
[ERROR] D:\Multi-module-project\StatisticsReport\src\main\java\com\yuewen\statistics\report\service\db\PullData.java:30: 警告: @param 没有说明
[ERROR] 
@param params
[ERROR] ^
[ERROR] D:\Multi-module-project\StatisticsReport\src\main\java\com\yuewen\statistics\report\service\db\PullData.java:31: 警告: @return 没有说明
[ERROR] @return
[ERROR] ^
[ERROR] D:\Multi-module-project\StatisticsReport\src\main\java\com\yuewen\statistics\report\service\db\PullData.java:32: 警告: @throws 没有说明
[ERROR] 
@throws SQLException
[ERROR] ^
[ERROR] D:\Multi-module-project\StatisticsReport\src\main\java\com\yuewen\statistics\report\service\db\PullData.java:34: 警告: logFlag没有 @param
[ERROR] public static ResultSet pullData(PreparedStatement preparedStatement, boolean logFlag, String… params) throws SQLException {
[ERROR] ^
[ERROR] D:\Multi-module-project\StatisticsReport\src\main\java\com\yuewen\statistics\report\service\db\PullData.java:51: 警告: @param 没有说明
[ERROR] @param preparedStatement
[ERROR] ^
[ERROR] D:\Multi-module-project\StatisticsReport\src\main\java\com\yuewen\statistics\report\service\db\PullData.java:52: 警告: @param 没有说明
[ERROR] 
@param params
[ERROR] ^
[ERROR] D:\Multi-module-project\StatisticsReport\src\main\java\com\yuewen\statistics\report\service\db\PullData.java:53: 警告: @return 没有说明
[ERROR] * @return
[ERROR] ^

经查得知,在JDK 8中,Javadoc中添加了doclint,而这个工具的主要目的是旨在获得符合W3C HTML 4.01标准规范的HTML文档,在JDK 8中,已经无法获取如下的Javadoc,除非它满足doclint

注意违反这些规则的话,将不会得到Javadoc的输出。

一种解决办法就是关闭doclint,如果你在Maven中运行,你需要使用additionalparam设置:

1
2
3
4
5
6
7
8
9
10
11
<profiles>
    <profile>
        <id>disable-javadoc-doclintid>
        <activation>
            <jdk>[1.8,)jdk>
        activation>
        <properties>
            <additionalparam>-Xdoclint:noneadditionalparam>
        properties>
    profile>
profiles>

 

或者是添加到maven-javadoc-plugin中:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<plugin>
    <groupId>org.apache.maven.pluginsgroupId>
    <artifactId>maven-javadoc-pluginartifactId>
    <version>2.10.4version>
    <configuration>
        <encoding>${chartset.UTF8}encoding>
        <aggregate>trueaggregate>
        <charset>${chartset.UTF8}charset>
        <docencoding>${chartset.UTF8}docencoding>
    configuration>
    <executions>
        <execution>
            <id>attach-javadocsid>
            <phase>packagephase>
            <goals>
                <goal>jargoal>
            goals>
            <configuration>
                <additionalparam>-Xdoclint:noneadditionalparam>
            configuration>
        execution>
    executions>
plugin>

 

你可能感兴趣的:(Java 8 配置Maven-javadoc-plugin)