项目目录下运行:
mvn dependency:sources -DdownloadSources=true -DdownloadJavadocs=true
或者:
mvn dependency:sources
mvn dependency:resolve -Dclassifier=javadoc
命令使用方法:首先进入到相应的pom.xml目录中,然后执行以上命令:
第一个命令是尝试下载在pom.xml中依赖的文件的源代码。
第二个命令:是尝试下载对应的javadocs
但是有可能一些文件没有源代码或者javadocs
2、通过maven的settings文件配置:
打开maven配置文件 setting.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
安装配置环境变量略过。
1)、修改本地仓库地址
在<localRepository>标签内添加自己的本地仓库路径
<!--自定义maven仓库路径-->
<localRepository>D:\maven\repo</localRepository>
2)、修改镜像
因为maven依赖的默认下载地址再海外,下载速度比较慢,有时候还可能下载不了,这时候我们可以通过修改镜像地址解决
添加<mirrors>标签下<mirror>,添加国内镜像源,这样下载jar包速度很快。一般使用阿里云镜像库即可。
<!-- 阿里云仓库 -->
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror>
3)、修改默认jdk版本(默认为1.4)
<profile>
<id>jdk-1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>