有人知道是否可以在Maven存储库中找到源jar吗?
当前回答
我还使用eclipse插件将项目放到eclipse工作区中。 因为我在一个不同的项目中工作过,我发现可以使用eclipse而不使用maven-eclipse-plugin。这使得它更容易在不同的环境中使用,并使maven比eclipse更容易使用。并且不需要更改pom.xml文件。
所以,我推荐加布里埃尔·拉米雷斯的方法。
其他回答
您可以在这个相关问题中找到相关信息:获取附加到Eclipse的源jar文件,以获得maven管理的依赖关系 如果你使用eclipse maven插件,那么使用'mvn eclipse:eclipse -DdownloadSources=true'
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
下载任何工件使用
mvn dependency:get -Dartifact=groupId:artifactId:version:packaging:classifier
对于Groovy源代码,这将是
mvn dependency:get -Dartifact=org.codehaus.groovy:groovy-all:2.4.6:jar:sources
对于Groovy的javadoc,您将使用
mvn dependency:get -Dartifact=org.codehaus.groovy:groovy-all:2.4.6:jar:javadoc
这将把给定的工件放到本地Maven存储库中,通常是$HOME/.m2/存储库。
Dependency:sources只下载项目依赖项的源代码,不下载插件源代码,也不下载插件内部定义的依赖项的源代码。
根据在Eclipse (Kepler)中查看Maven控制台,如果您试图在编辑器中从上述Maven依赖项打开一个类,而您还没有下载Maven依赖项的源代码,则将自动下载Maven依赖项的源代码。当您不想为所有依赖项获取源代码,但又不知道需要哪些依赖项时(而且您正在使用Eclipse),这是非常方便的。
我最终使用了@GabrielRamierez的方法,但接下来将使用@PascalThivent的方法。
如果你正在使用eclipse,你也可以打开Preferences > Maven并选择下载Artifact Sources,这将使pom.xml保持完整,并将你的源代码或java文档(如果选中)保存在你的机器位置~/.m2中进行开发
推荐文章
- javax.transaction.Transactional vs . org.springframework.transaction.annotation.Transactional
- Java 8接口方法中不允许“同步”的原因是什么?
- 如何找到Java堆大小和内存使用(Linux)?
- 使用Enum实现单例(Java)
- RabbitMQ与通道和连接之间的关系
- buildSessionFactory()配置方法在Hibernate中已弃用?
- Spring MVC -如何获得所有的请求参数在一个地图在Spring控制器?
- 如何在Java中按两个字段排序?
- 文件之间的差异。路径中的分隔符和斜杠
- 在方法参数中使用NotNull注释
- Spring MVC中处理可选参数的@RequestParam
- 禁用maven下载进度指示
- Tomcat:如何查找正在运行的Tomcat版本?
- “java”、“javaw”和“javaws”之间有什么区别?
- 将Date对象转换为日历对象