sources not found for【IDEA】

痛定思痛。 2022-04-04 07:56 793阅读 0赞

方法一:

add <classifier>sources</classifier>

example:

  1. <dependency>
  2. <groupId>xxx</groupId>
  3. <artifactId>xxx</artifactId>
  4. <version>xxx</version>
  5. <classifier>sources</classifier>
  6. </dependency>

方法二

使用【maven-eclipse-plugin】插件

  1. <build>
  2. <plugins>
  3. <plugin>
  4. <groupId>org.apache.maven.plugins</groupId>
  5. <artifactId>maven-eclipse-plugin</artifactId>
  6. <configuration>
  7. <downloadSources>true</downloadSources>
  8. <downloadJavadocs>true</downloadJavadocs>
  9. </configuration>
  10. </plugin>
  11. </plugins>
  12. </build>

方法三

使用mvn命令 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.

  1. mvn dependency:sources
  2. 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:

  1. mvn dependency:sources -DincludeArtifactIds=guava

本文参考: https://stackoverflow.com/questions/2059431/get-source-jars-from-maven-repository

发表评论

表情:
评论列表 (有 0 条评论,793人围观)

还没有评论,来说两句吧...

相关阅读

    相关 eclipse source not found 问题

    学习项目代码的时候想要看一下Cookie的源码,已经确定下载到了本地,可是Ctrl+左键点进去,提示source not found(如下图),灰常纳闷,遂百度,大家普遍认为需