介紹
- 開發(fā)時(shí),有時(shí)想查看一下源碼或者文檔文件,當(dāng)然并不是所有依賴都有源碼和文檔,所以對(duì)于沒有的也沒辦法了。下載好源碼通過開發(fā)工具就導(dǎo)入jar包看了。
- 下面就介紹3中方法下載依賴的源碼和javadoc。
1:Maven命令下載源碼和javadocs
mvn dependency:sources
mvn dependency:resolve -Dclassifier=javadoc
命令使用方法:首先進(jìn)入到相應(yīng)的pom.xml目錄中,然后執(zhí)行以上命令:
第一個(gè)命令是嘗試下載在pom.xml中依賴的文件的源代碼。
第二個(gè)命令:是嘗試下載對(duì)應(yīng)的javadocs
但是有可能一些文件沒有源代碼或者javadocs
2:通過配置文件添加
打開maven配置文件 setting.xml文件(.../.m2/settings.xml) 增加如下配置:
<profiles>
<profile>
<id>downloadSources</id>
<properties>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>downloadSources</activeProfile>
</activeProfiles>
3:配置eclipse
- Window > Preferences > Maven and checking the "Download Artifact Sources" and "Download Artifact JavaDoc" options

Paste_Image.png