码迷,mamicode.com
首页 > 编程语言 > 详细

maven中下载jar包源码和javadoc

时间:2017-09-11 11:30:52      阅读:243      评论:0      收藏:0      [点我收藏+]

标签:pom   spec   ror   init   epo   eprof   exe   sdn   技术   

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

maven中下载jar包源码和javadoc

标签:pom   spec   ror   init   epo   eprof   exe   sdn   技术   

原文地址:http://www.cnblogs.com/anstoner/p/7504079.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!