操作步骤
使用maven生成doc 正常情况下还是很简单的在pom里面配置一个javadoc的插件,然后可以在指定的maven寿命周期上绑定插件的配置如下:
4.0.0 com.qhy.demo DocGen 0.0.1-SNAPSHOT sss ddddd org.apache.maven.plugins maven-javadoc-plugin 2.10.3 attach-javadoc package jar public UTF-8 UTF-8 UTF-8 com.alibaba.com.* http://docs.oracle.com/javase/6/docs/api
开始的错误日志:
[INFO] --- maven-jar-plugin:2.3.2:jar (default-jar) @ DocGen --- [INFO] Building jar: E:\work\workspace_dubbo\DocGen\target\DocGen-0.0.1-SNAPSHOT.jar [INFO] [INFO] --- maven-javadoc-plugin:2.10.3:jar (attach-javadoc) @ DocGen --- [INFO] 正在装入软件包 com.qhy.gen 的源文件... 正在构造 Javadoc 信息... 标准 Doclet 版本 1.6.0_39 正在构建所有软件包和类的树... 正在生成 E:/work/workspace_dubbo/DocGen/target/apidocs\com/qhy/gen/\Test.html... [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 7.850s [INFO] Finished at: Fri Jun 03 15:16:57 CST 2016 [INFO] Final Memory: 18M/157M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.10.3:jar (attach-javadoc) on project DocGen: MavenReportException: Error while generating Javadoc: [ERROR] Exit code: 1 - java.lang.IllegalArgumentException [ERROR] at sun.net.www.ParseUtil.decode(ParseUtil.java:189) [ERROR] at sun.misc.URLClassPath$FileLoader.(URLClassPath.java:958) [ERROR] at sun.misc.URLClassPath$3.run(URLClassPath.java:328) [ERROR] at java.security.AccessController.doPrivileged(Native Method) [ERROR] at sun.misc.URLClassPath.getLoader(URLClassPath.java:322) [ERROR] at sun.misc.URLClassPath.getLoader(URLClassPath.java:299) [ERROR] at sun.misc.URLClassPath.findResource(URLClassPath.java:145) [ERROR] at java.net.URLClassLoader$2.run(URLClassLoader.java:385) [ERROR] at java.security.AccessController.doPrivileged(Native Method) [ERROR] at java.net.URLClassLoader.findResource(URLClassLoader.java:382) [ERROR] at java.lang.ClassLoader.getResource(ClassLoader.java:1002) [ERROR] at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:1192) [ERROR] at javax.xml.parsers.SecuritySupport$4.run(SecuritySupport.java:96) [ERROR] at java.security.AccessController.doPrivileged(Native Method) [ERROR] at javax.xml.parsers.SecuritySupport.getResourceAsStream(SecuritySupport.java:89) [ERROR] at javax.xml.parsers.FactoryFinder.findJarServiceProvider(FactoryFinder.java:250) [ERROR] at javax.xml.parsers.FactoryFinder.find(FactoryFinder.java:223) [ERROR] at javax.xml.parsers.SAXParserFactory.newInstance(SAXParserFactory.java:128) [ERROR] at com.sun.tools.doclets.internal.toolkit.builders.LayoutParser.parseXML(LayoutParser.java:72) [ERROR] at com.sun.tools.doclets.internal.toolkit.builders.ClassBuilder.build(ClassBuilder.java:108) [ERROR] at com.sun.tools.doclets.formats.html.HtmlDoclet.generateClassFiles(HtmlDoclet.java:155) [ERROR] at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.generateClassFiles(AbstractDoclet.java:164) [ERROR] at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.startGeneration(AbstractDoclet.java:106) [ERROR] at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.start(AbstractDoclet.java:64) [ERROR] at com.sun.tools.doclets.formats.html.HtmlDoclet.start(HtmlDoclet.java:42) [ERROR] at com.sun.tools.doclets.standard.Standard.start(Standard.java:23) [ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [ERROR] at java.lang.reflect.Method.invoke(Method.java:597) [ERROR] at com.sun.tools.javadoc.DocletInvoker.invoke(DocletInvoker.java:269) [ERROR] at com.sun.tools.javadoc.DocletInvoker.start(DocletInvoker.java:143) [ERROR] at com.sun.tools.javadoc.Start.parseAndExecute(Start.java:340) [ERROR] at com.sun.tools.javadoc.Start.begin(Start.java:128) [ERROR] at com.sun.tools.javadoc.Main.execute(Main.java:41) [ERROR] at com.sun.tools.javadoc.Main.main(Main.java:31) [ERROR] com.sun.tools.doclets.internal.toolkit.util.DocletAbortException [ERROR] at com.sun.tools.doclets.internal.toolkit.builders.LayoutParser.parseXML(LayoutParser.java:79) [ERROR] at com.sun.tools.doclets.internal.toolkit.builders.ClassBuilder.build(ClassBuilder.java:108) [ERROR] at com.sun.tools.doclets.formats.html.HtmlDoclet.generateClassFiles(HtmlDoclet.java:155) [ERROR] at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.generateClassFiles(AbstractDoclet.java:164) [ERROR] at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.startGeneration(AbstractDoclet.java:106) [ERROR] at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.start(AbstractDoclet.java:64) [ERROR] at com.sun.tools.doclets.formats.html.HtmlDoclet.start(HtmlDoclet.java:42) [ERROR] at com.sun.tools.doclets.standard.Standard.start(Standard.java:23) [ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [ERROR] at java.lang.reflect.Method.invoke(Method.java:597) [ERROR] at com.sun.tools.javadoc.DocletInvoker.invoke(DocletInvoker.java:269) [ERROR] at com.sun.tools.javadoc.DocletInvoker.start(DocletInvoker.java:143) [ERROR] at com.sun.tools.javadoc.Start.parseAndExecute(Start.java:340) [ERROR] at com.sun.tools.javadoc.Start.begin(Start.java:128) [ERROR] at com.sun.tools.javadoc.Main.execute(Main.java:41) [ERROR] at com.sun.tools.javadoc.Main.main(Main.java:31) [ERROR] com.sun.tools.doclets.internal.toolkit.util.DocletAbortException [ERROR] at com.sun.tools.doclets.formats.html.HtmlDoclet.generateClassFiles(HtmlDoclet.java:159) [ERROR] at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.generateClassFiles(AbstractDoclet.java:164) [ERROR] at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.startGeneration(AbstractDoclet.java:106) [ERROR] at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.start(AbstractDoclet.java:64) [ERROR] at com.sun.tools.doclets.formats.html.HtmlDoclet.start(HtmlDoclet.java:42) [ERROR] at com.sun.tools.doclets.standard.Standard.start(Standard.java:23) [ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [ERROR] at java.lang.reflect.Method.invoke(Method.java:597) [ERROR] at com.sun.tools.javadoc.DocletInvoker.invoke(DocletInvoker.java:269) [ERROR] at com.sun.tools.javadoc.DocletInvoker.start(DocletInvoker.java:143) [ERROR] at com.sun.tools.javadoc.Start.parseAndExecute(Start.java:340) [ERROR] at com.sun.tools.javadoc.Start.begin(Start.java:128) [ERROR] at com.sun.tools.javadoc.Main.execute(Main.java:41) [ERROR] at com.sun.tools.javadoc.Main.main(Main.java:31) [ERROR] [ERROR] Command line was: D:\devtools\Java\jdk1.6.0_39\jre\..\bin\javadoc.exe @options @packages [ERROR] [ERROR] Refer to the generated Javadoc files in 'E:\work\workspace_dubbo\DocGen\target\apidocs' dir. [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException D:\devtools\Java\jdk1.6.0_39\lib\tools.jar;D:\devtools\Java\jdk1.6.0_39\jre\lib\rt.jar
解决方法:
这个问题是由于java环境变量配置造成的,我开始是.;%javahome%\jre\lib\tools.jar;%javahome%\jre\lib\dt.jar
后来改为:.;D:\devtools\Java\jdk1.6.0_39\lib\tools.jar;D:\devtools\Java\jdk1.6.0_39\jre\lib\rt.jar
后来重启电脑,才好的;不重启还是不行,另一个项目还有点问题,大概可以确定是环境的问题。大家不要像我一样在pom配置上找了半天。