Java 无法使用 Intellij Idea 社区 12.1.4 和 maven 3.0.5 下载源代码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18779183/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 10:59:03  来源:igfitidea点击:

Can not download sources with Intellij Idea community 12.1.4 and maven 3.0.5

javamavenintellij-idea

提问by Cherry

I click "download sources and documentation" in Intellij Idea Community Edition 12.1.4 and get error that sources can not be downloaded. But when I try:

我在 Intellij Idea Community Edition 12.1.4 中单击“下载源代码和文档”并收到无法下载源代码的错误消息。但是当我尝试:

mvn dependency:sources

All sources are downloaded.

下载所有源。

What is the problem?

问题是什么?

P.S.I have checked that Idea use the same maven that use in console. There are not any "off line" mode buttons triggered in Idea.

PS我已经检查过 Idea 使用与控制台中使用的相同的 Maven。Idea 中没有触发任何“离线”模式按钮。

采纳答案by ingara

Running IDEA version 12.1.6and I have the same issue.

跑步IDEA version 12.1.6和我有同样的问题。

When I uncheck the following option it does work:

当我取消选中以下选项时,它确实有效:

Settings > Maven > Importing > Use Maven3 to import project

Settings > Maven > Importing > Use Maven3 to import project

回答by Chakra

In Intellij 2017.x, 2016.x, 15.x, 14.xthe given solution does not work as the option is removed.

Intellij 2017.x、2016.x、15.x、14.x 中,由于删除了该选项因此给定的解决方案不起作用。

The problem can be solved by changing JDK for Importerto a latest JDK instead of User Internal JREwhich was 1.6.0 by default on Mac

问题可以通过更改JDK for Importer为最新的 JDK 而不是User Internal JREMac 上默认的 1.6.0来解决

The setting JDK For Importercan be found in:

该设置JDK For Importer可以在以下位置找到:

Preferences -> Build, Execution,Deployment -> Build Tools -> Maven -> Importing

首选项 -> 构建、执行、部署 -> 构建工具 -> Maven -> 导入

回答by xtermi2

I had the same issue with IntelliJ IDEA 2016.1.3and Maven 3.2.1. No solution mentioned here was working. In my case a newer Maven version fixed the issue. With Maven 3.3.9IDEA can now download the sources.

我在 IntelliJ IDEA 2016.1.3Maven 3.2.1 上遇到了同样的问题。这里提到的解决方案都没有奏效。就我而言,较新的 Maven 版本解决了该问题。随着Maven 3.3.9IDEA 现在可以下载源代码。

回答by kj6682

"I had the same issue with IntelliJ IDEA 2016.1.3 and Maven 3.2.1. No solution mentioned here was working. In my case a newer Maven version fixed the issue. With Maven 3.3.9 IDEA can now download the sources."

“我在 IntelliJ IDEA 2016.1.3 和 Maven 3.2.1 上遇到了同样的问题。这里提到的解决方案都没有工作。在我的情况下,一个较新的 Maven 版本解决了这个问题。使用 Maven 3.3.9 IDEA 现在可以下载源代码。”

anything's already in the former answers...

以前的答案中已经有任何内容......

  • download sources in your repo mvn dependency:sources
  • F4 on the class you want to check the sources out
  • locate the source jar in your local repository
  • 在你的仓库中下载源代码 mvn dependency:sources
  • F4 在您要查看来源的课程上
  • 在本地存储库中找到源 jar

maybe it is not a full IDE solution, but hope it solves your issue

也许它不是一个完整的 IDE 解决方案,但希望它能解决您的问题

回答by Kwyjibo

Had the same issue with IntelliJ 2016.2.4. As user526177 posted udating the Maven version fixes it but for my needs switching to the bundled Maven 2 was just fine and fixed the issue.

IntelliJ 2016.2.4 也有同样的问题。正如 user526177 发布的 udating Maven 版本修复了它,但为了我的需要,切换到捆绑的 Maven 2 就好了并解决了这个问题。

Screenshot (can't embed yet due to rank)

屏幕截图(由于排名无法嵌入)

回答by mark

I solve this by use jdk 1.8 in MAVEN -> RUNNER -> JRE .my idea version is 2016.2

我通过在 MAVEN -> RUNNER -> JRE 中使用 jdk 1.8 解决了这个问题。我的想法版本是 2016.2

回答by guamiansang

I use IDEA 2017.1.3, I just change the Maven home directory option(Preferences -> Build, Execution,Deployment -> Build Tools -> Maven -> Maven home directory) of default Maven 3 to Maven 2, I believe it's the same solution for newer version of IDEA just like the selected answer. And it works for me.

我使用 IDEA 2017.1.3,我只是将默认 Maven 3 的 Maven 主目录选项(首选项 -> 构建、执行、部署 -> 构建工具 -> Maven -> Maven 主目录)更改为 Maven 2,我相信它是相同的新版 IDEA 的解决方案就像所选答案一样。它对我有用。

回答by Brian Agnew

I had this issue, and sources weren't being downloaded since I needed credentials from my project's specificsettings.xml.

我遇到了这个问题,并且没有下载源代码,因为我需要来自项目特定settings.xml.

To fix (Intellij 2018.1.2):

修复(Intellij 2018.1.2):

File -> Settings -> Build, Execution, Deployment -> Maven

文件 -> 设置 -> 构建、执行、部署 -> Maven

and provide the appropriate settings.xmlin the 'User settings file' section

settings.xml在“用户设置文件”部分提供适当的

回答by light77

I changed the java version in pom.xml to match my jdk's version and it worked for me.

我更改了 pom.xml 中的 java 版本以匹配我的 jdk 版本,它对我有用。

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

     <!--earlier this was 1.8-->
    <java.version>10</java.version>

</properties>