简体   繁体   English

Intellij IDEA 未检测到更改

[英]Intellij IDEA doesn't detect changes

Yesterday I refactored my project and I changed layout of my packages (I moved some packages into another packages, created new packages etc).昨天我重构了我的项目并更改了包的布局(我将一些包移动到另一个包中,创建了新包等)。 But now, when I try to run JUnit test I get NoSuchMethodError on methods which name is changed after refactoring.但是现在,当我尝试运行 JUnit 测试时,我在重构后更改名称的方法上得到NoSuchMethodError Also, when I change other code in methods, IDEA still running old code.. I tried to run "Invalidate caches" in File menu, also I tried to reboot computer - no result.此外,当我更改方法中的其他代码时,IDEA 仍在运行旧代码。我尝试在文件菜单中运行“无效缓存”,也尝试重新启动计算机 - 没有结果。 Where can be problem?哪里可能有问题?

EDIT: Yesterday after moving packages IDEA doesn't correctly change package declarations in .java files, so I changed them by hand编辑:昨天移动包后,IDEA 没有正确更改.java文件中的 package 声明,所以我手动更改了它们

当 Intellij 突然停止注意到变化时,VCS -> Refresh File Status 为我解决了这个问题。

SOLUTION:解决方案:

Error magically gone after 2 things:错误在两件事之后神奇地消失了:

  1. I imported this project into eclipse and run JUNit test from eclipse.我将这个项目导入到 eclipse 中并从 eclipse 运行 JUNit 测试。 Then I returned to IDEA and deleted all Eclipse specific files.然后我返回到 IDEA 并删除了所有 Eclipse 特定文件。

  2. I synchronized my project (File->Synchronize).我同步了我的项目(文件->同步)。

I don't know what actually was the solution of problem, but for suggestions I accept @SeanLandsman's answer我不知道问题的实际解决方案是什么,但对于建议,我接受@SeanLandsman 的回答

Answer to an old question, but:回答一个老问题,但是:

If you're using a Run Configuration, make sure in the "Before Launch" section of the "Run/Debug Configurations" dialog, you have added "Build".如果您使用的是运行配置,请确保在“运行/调试配置”对话框的“启动前”部分中添加了“构建”。 It seems to get removed from this dialog sometimes, even if you have it added in the default settings.它似乎有时会从此对话框中删除,即使您已将其添加到默认设置中。

What I did in order to solve the issue was to "invalidate and Restart":为了解决这个问题,我所做的是“无效并重新启动”:

在此处输入图片说明

File -> invalidate and Restart文件 -> 无效并重新启动

I have two suggestions you could try here我有两个建议你可以在这里试试

  • Edit your test configuration(s) and ensure that they're pointing to what you expect them to.编辑您的测试配置并确保它们指向您期望的内容。 I've sometimes seen a refactoring not being picked up in the run configuration and I've had to manually change it我有时会看到在运行配置中没有进行重构,我不得不手动更改它
  • Less likely to work, but try to synchronize your project: File->Synchronize.不太可能工作,但尝试同步您的项目:文件->同步。 Do this at the highest level of your project在项目的最高级别执行此操作

With regards to your edit - I've not seen this myself.关于您的编辑 - 我自己没有见过。 Whenever I've renamed or moved files (including packages) these changes have been correctly applied to all applicable files.每当我重命名或移动文件(包括包)时,这些更改都已正确应用于所有适用的文件。 Are you refactoring with Refactor>Move / Refactor->Copy ?您是否使用 Refactor>Move / Refactor->Copy 进行重构?

删除类目录的全部内容对我有用

Another root-cause can be:另一个根本原因可能是:

If you are using Lombok, try to deinstall/reinstall the Intellij Lombok Plugin.如果您使用的是 Lombok,请尝试卸载/重新安装 Intellij Lombok 插件。

That solved such a strange behaviour in my case!就我而言,这解决了这种奇怪的行为!

尝试删除抛出 nosuchmethod 错误的类的 .class 文件,然后重新编译。

This worked for me.这对我有用。

In IntelliJ IDEA,在 IntelliJ IDEA 中,

  1. Right click on the project.右键单击项目。
  2. Select Git -> Show History.选择 Git -> 显示历史记录。
  3. Opens "Version Control"打开“版本控制”

Then you can navigate to Local Changes Tab.然后您可以导航到本地更改选项卡。

Found this posting from IntelliJ and Maven not finding POM changes.从 IntelliJ 和 Maven 中找到此帖子,但未找到 POM 更改。 Had to Reload All Maven projects to fix it.必须重新加载所有 Maven 项目来修复它。 Maven panel, upper left corner circle of arrows button. Maven 面板,箭头按钮的左上角圆圈。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM