博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
maven学习笔记(一)maven下载javadoc和源码
阅读量:6860 次
发布时间:2019-06-26

本文共 1890 字,大约阅读时间需要 6 分钟。

  hot3.png

Maven命令下载源码和javadocs

当在IDE中使用Maven时如果想要看引用的jar包中类的源码和javadoc需要通过maven命令下载这些源码,然后再进行引入,通过mvn命令能够容易的达到这个目的:

mvn dependency:sources

mvn dependency:resolve -Dclassifier=javadoc

命令使用方法:首先进入到相应的pom.xml目录中,然后执行以上命令:

第一个命令是尝试下载在pom.xml中依赖的文件的源代码。

第二个命令:是尝试下载对应的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

转者再补充一个方式,在pom.xml添加如下内容:

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-eclipse-plugin</artifactId>
                <configuration>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>true</downloadJavadocs>
                </configuration>
            </plugin>
        </plugins>

    </build>

maven中添加远程仓库:

<profile>

      <id>dev</id>
 <repositories>  
<repository>  
 <id>company</id>  
 <name>company</name>  
 <url>http://192.168.2.202:8081/nexus/content/repositories/releases/</url>  
 <releases>  
<enabled>true</enabled>  
 </releases>  
 <snapshots>  
<enabled>false</enabled>  
 </snapshots>  
</repository>  
 </repositories>  
 <pluginRepositories>  
<pluginRepository>  
 <id>company</id>  
 <name>company</name>  
 <url>http://192.168.2.202:8081/nexus/content/repositories/releases/</url>  
 <releases>  
<enabled>true</enabled>  
 </releases>  
 <snapshots>  
<enabled>false</enabled>  
 </snapshots>      
</pluginRepository>  
 </pluginRepositories>    
    </profile>

把URL改写成自己的:

推荐maven仓库:

同时在pom.xml中的setting中的文件

<activeProfiles>

    <activeProfile>dev</activeProfile>
  </activeProfiles>

从Maven仓库中导出jar包:进入工程pom.xml 所在的目录下,输入:

mvn dependency:copy-dependencies -DoutputDirectory=lib  

转载于:https://my.oschina.net/liting/blog/355795

你可能感兴趣的文章
Oracle重量级表的优化查询处理
查看>>
软件包管理器
查看>>
cactiEZ不显示图像的问题
查看>>
Debian wheezy下通过apt安装nginx
查看>>
Symantec备份之(3)安装Agent for linux server - 潜入技术的海洋
查看>>
看得清楚,活得明白
查看>>
Powershell 远程管理Exchange2010配置
查看>>
SCCM2012系列之二,SCCM2012部署前的Active Directory准备
查看>>
我的友情链接
查看>>
Cacti 0.8.7g for windows_落英缤纷
查看>>
Linux 初级优化
查看>>
解决内存不能为read的方法
查看>>
Windows 7系統庫功能小技巧
查看>>
OpenCV编程->cvMeanShift函数
查看>>
easyUI 数据表格 没有数据 只有列超过datagrid的宽度时候不显示横向滚动条
查看>>
JNA
查看>>
iOS培训——Cocos2dx基础篇AppDelegate
查看>>
SQL语句优化
查看>>
Junit 小案例 测试超时
查看>>
zookeeper 集群安装
查看>>