當(dāng)在IDE中使用Maven時(shí)如果想要看引用的jar包中類的源碼和javadoc需要通過maven命令下載這些源碼,然后再進(jìn)行引入,通過mvn命令能夠容易的達(dá)到這個(gè)目的:
mvn dependency:sources
mvn dependency:resolve -Dclassifier=javadoc
命令使用方法:首先進(jìn)入到相應(yīng)的pom.xml目錄中,然后執(zhí)行以上命令:
第一個(gè)命令是嘗試下載在pom.xml中依賴的文件的源代碼。
第二個(gè)命令:是嘗試下載對應(yīng)的javadocs
但是有可能一些文件沒有源代碼或者javadocs
參考文章:reference
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