用maven管理Jar包很方便,代码存入远程仓库也不用因为Jar文件太大而占用太多的空间。还有一个好处是可以自动下载第三方jar包的源码,不过会出现下载不到的情况,这个时候需要检查一下环境。
eclipse的设置:
勾选windows-Preferences-Maven-Download Artifact Sources 这个选项
下载源码包的方法:
使用maven命令行下载依赖包的源代码:
mvn dependency:sources
mvn dependency:sources -DdownloadSources=true -DdownloadJavadocs=true
-DdownloadSources=true 下载源代码Jar -DdownloadJavadocs=true 下载javadoc包
如果执行后还是没有下载到,可以到仓库上搜一下,比如我这里搜的这个:
spring-data-jpa-1.2.0.RC1-sources.jar
http://search.maven.org/#search|gav|1|g%3A"org.springframework.data" AND a%3A"spring-data-jpa"
下载下来放到本地仓库,在eclise里面设置下关联就可以了。