Maven获取工程相关仓库的源码和javadoc方法

 背景

编写程序和研读代码时,离不开仓库的源码和javadoc,如何将相关文档添加到工程中非常重要。

获取方法

进入工程的根目录,运行下列命令:

mvn dependency:sources -DdownloadSources=true -DdownloadJavadocs=true
 
 Maven将开始下载源码与javadoc相关jar文件,下载完成后,会提示最终下载到的source情况:

[INFO]
[INFO] The following files have been resolved:
[INFO]    antlr:antlr:java-source:sources:2.7.6
[INFO]    commons-collections:commons-collections:java-source:sources:3.1
[INFO]    dom4j:dom4j:java-source:sources:1.6.1
[INFO]    javax.transaction:jta:java-source:sources:1.1
[INFO]    org.hibernate:hibernate-core:java-source:sources:3.3.2.GA
[INFO]    org.slf4j:slf4j-api:java-source:sources:1.5.8
[INFO]    xml-apis:xml-apis:java-source:sources:1.0.b2
[INFO]
[INFO] The following files have NOT been resolved:
[INFO]    mysql:mysql-connector-java:java-source:sources:5.1.34
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3:10.794s
[INFO] Finished at: Mon Jan 26 17:21:39 CST 2015
[INFO] Final Memory: 10M/70M
[INFO] ------------------------------------------------------------------------
e:\workspace\hibernate>

在Eclipse中通过点击工程-->右键-->Maven-->Update Project,来更新工程;之后,就可以在工程中看到源码和帮助信息。

参数介绍

-DdownloadSources=true:   下载源代码jar

-DdownloadJavadocs=true: 下载javadoc包


你可能感兴趣的:(Maven获取工程相关仓库的源码和javadoc方法)