有人知道是否可以在Maven存储库中找到源jar吗?


当前回答

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

其他回答

在eclipse中-点击项目然后:

.

IntelliJ idea的maven idea插件允许您指定是否应该解析和下载源代码和java文档

mvn idea:idea -DdownloadSources=true -DdownloadJavadocs=true

如果您想手动找到任何工件的源jar文件,请转到特定工件的maven存储库位置,并在Files中单击“view All”。你可以找到源jar文件。

NetBeans, Context-Click

在NetBeans 8的maven驱动项目中,只需上下文单击感兴趣的依赖项的jar文件列表项。选择“下载源”。稍等片刻,NetBeans将自动下载并安装源代码(如果可用的话)。

类似地,您可以选择Download Javadoc以在本地安装文档。然后,您可以在编辑器中上下文单击一些代码并选择查看JavaDoc。

如果你知道groupId和aritifactId,你可以像这样生成下载url。

    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>1.2.3</version>
    </dependency>

http://central.maven.org/maven2/ch/qos/logback/logback-classic/

你会得到一个像这样的页面,选择你需要的版本,只是享受它!