maven中下載jar包源碼和javadoc


1:Maven命令下載源碼和javadocs

當在IDE中使用Maven時如果想要看引用的jar包中類的源碼和javadoc需要通過maven命令下載這些源碼,然后再進行引入,通過mvn命令能夠容易的達到這個目的:

 

mvn dependency:sources mvn dependency:resolve -Dclassifier=javadoc

命令使用方法:首先進入到相應的pom.xml目錄中,然后執行以上命令:

 

第一個命令是嘗試下載在pom.xml中依賴的文件的源代碼。

第二個命令:是嘗試下載對應的javadocs

但是有可能一些文件沒有源代碼或者javadocs

reference

Executing mvn dependency:sources will force maven to download all sources of all jars in the project, if the sources are available (are uploaded in the repository where the artifact is hosted). If you want to download javadoc the command is mvn dependency:resolve -Dclassifier=javadoc

http://stackoverflow.com/questions/11361331/how-to-download-sources-for-a-jar-with-maven

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
 
參考;
http://blog.csdn.net/topwqp/article/details/8902863
 
 

Maven編譯報錯 Unknown lifecycle phase "mvn" 解決辦法

[ERROR] Unknown lifecycle phase "mvn". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]

 搜索到一個靠譜的回答:

如果是eclipse繼承環境,去掉mvn

 
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM