有人知道是否可以在Maven存储库中找到源jar吗?
当前回答
NetBeans, Context-Click
在NetBeans 8的maven驱动项目中,只需上下文单击感兴趣的依赖项的jar文件列表项。选择“下载源”。稍等片刻,NetBeans将自动下载并安装源代码(如果可用的话)。
类似地,您可以选择Download Javadoc以在本地安装文档。然后,您可以在编辑器中上下文单击一些代码并选择查看JavaDoc。
其他回答
根据在Eclipse (Kepler)中查看Maven控制台,如果您试图在编辑器中从上述Maven依赖项打开一个类,而您还没有下载Maven依赖项的源代码,则将自动下载Maven依赖项的源代码。当您不想为所有依赖项获取源代码,但又不知道需要哪些依赖项时(而且您正在使用Eclipse),这是非常方便的。
我最终使用了@GabrielRamierez的方法,但接下来将使用@PascalThivent的方法。
Maven Micro-Tip: Get sources and Javadocs When you're using Maven in an IDE you often find the need for your IDE to resolve source code and Javadocs for your library dependencies. There's an easy way to accomplish that goal. mvn dependency:sources mvn dependency:resolve -Dclassifier=javadoc The first command will attempt to download source code for each of the dependencies in your pom file. The second command will attempt to download the Javadocs. Maven is at the mercy of the library packagers here. So some of them won't have source code packaged and many of them won't have Javadocs. In case you have a lot of dependencies it might also be a good idea to use inclusions/exclusions to get specific artifacts, the following command will for example only download the sources for the dependency with a specific artifactId: mvn dependency:sources -DincludeArtifactIds=guava
来源:http://tedwise.com/2010/01/27/maven-micro-tip-get-sources-and-javadocs/
文档:https://maven.apache.org/plugins/maven-dependency-plugin/sources-mojo.html
配置和运行maven-eclipse插件(例如从命令行mvn eclipse:eclipse)
<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>
您可以在这个相关问题中找到相关信息:获取附加到Eclipse的源jar文件,以获得maven管理的依赖关系 如果你使用eclipse maven插件,那么使用'mvn eclipse:eclipse -DdownloadSources=true'
在IntelliJ IDEA中,您可以在导入时通过打开“自动下载源”选项自动下载工件源:
设置→构建、执行、部署→构建工具→Maven→导入