IntelliJ无法从本地Maven存储库加载源 [英] IntelliJ cannot load sources from local Maven repository

查看:1191
本文介绍了IntelliJ无法从本地Maven存储库加载源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一些需要在JUnit中使用我不熟悉的功能的测试工作。为了更好地理解这些功能,我希望能够在我的项目中查看IntelliJ内的JUnit源。

I'm doing some testing work that requires the use of features in JUnit which are unfamiliar to me. In order to better understand these features I'd like to be able to view the JUnit sources inside IntelliJ alongside my project.

这个项目使用Maven。我对pom.xml文件中列出的jUnit有以下依赖关系:

This project uses Maven. I have the following dependency for jUnit listed in my pom.xml file:

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.10</version>
    </dependency>

当我在命令行上运行mvn clean install时,jUnit源代码从我公司的Maven下载存储库到我的本地Maven存储库(.m2目录)。然后项目编译并运行没有问题。

When I run "mvn clean install" on the command line the jUnit sources are downloaded from my company's Maven repository into my local Maven repository (.m2 directory). The project then compiles and runs without issue.

右键单击pom.xml文件并选择Maven-> Reimport后,我可以看到类,源和jUnit的javadocs也出现在IntelliJ的库设置中:

After right-clicking on the pom.xml file and selecting Maven->Reimport I can see that the classes, sources, and javadocs for jUnit are also present in the library settings in IntelliJ:

但是,当我尝试在IntelliJ中打开一个jUnit类文件并单击下载源链接时,我看到这个:

However, when I try to open a jUnit class file in IntelliJ and click on the "Download Sources" link I see this:

似乎IntelliJ应该在本地找到这些来源。即使它必须从我公司的存储库下载它们,我也相信它应该在那里找到它们,因为那是我本地存储库中的junit-4.10-sources.jar文件最初的来源。

It seems to might like IntelliJ should be finding these sources just fine locally. Even if it did have to download them from my company's repository I also believe it should find them there since that's where the junit-4.10-sources.jar file in my local repository originally came from.

什么可能阻止IntelliJ加载它已经知道的JAR文件中的源?

What might be keeping IntelliJ from loading the sources from the JAR file that it already knows about?

推荐答案

我能够在Windows上的IntelliJ 16中复制它。

I was able to replicate this in IntelliJ 16 on Windows.

以下是我的解决方法:


  1. 选择文件 - >设置 - >构建,执行,部署 - >构建工具 - > Maven - >存储库

  2. 从列表中选择您的本地存储库(如果不存在,则添加它)

  3. 点击更新按钮

  4. 点击确定

  5. 右键单击 pom.xml 文件并选择Maven - > Reimport

  1. Choose file -> Settings -> Build, Execution, Deployment -> Build Tools -> Maven -> Repositories
  2. Select Your local repository from the list (or add it if it is not there)
  3. Click the 'Update' button
  4. Click ok
  5. Right click your pom.xml file and select Maven -> Reimport

这篇关于IntelliJ无法从本地Maven存储库加载源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆