简体   繁体   中英

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. 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. 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

当 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. Then I returned to IDEA and deleted all Eclipse specific files.

  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

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 ?

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

Another root-cause can be:

If you are using Lombok, try to deinstall/reinstall the Intellij Lombok Plugin.

That solved such a strange behaviour in my case!

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

This worked for me.

In IntelliJ IDEA,

  1. Right click on the project.
  2. Select Git -> Show History.
  3. Opens "Version Control"

Then you can navigate to Local Changes Tab.

Found this posting from IntelliJ and Maven not finding POM changes. Had to Reload All Maven projects to fix it. Maven panel, upper left corner circle of arrows button.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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