java Intellij IDEA 不检测更改
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15020432/
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
Intellij IDEA doesn't detect changes
提问by MyTitle
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?
昨天我重构了我的项目并更改了我的包的布局(我将一些包移到另一个包中,创建了新包等)。但是现在,当我尝试运行 JUnit 测试时,我遇到NoSuchMethodError
了重构后名称已更改的方法。此外,当我更改方法中的其他代码时,IDEA 仍在运行旧代码。我尝试在“文件”菜单中运行“无效缓存”,也尝试重新启动计算机 - 没有结果。哪里会出问题?
EDIT: Yesterday after moving packages IDEA doesn't correctly change package declarations in .java
files, so I changed them by hand
编辑:昨天移动包后,IDEA 没有正确更改.java
文件中的包声明,所以我手动更改了它们
采纳答案by Sean Landsman
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 进行重构?
回答by Stoffe
VCS -> Refresh File Status solved this for me, when Intellij suddenly stopped noticing changes.
当 Intellij 突然停止注意到变化时,VCS -> 刷新文件状态为我解决了这个问题。
回答by MyTitle
SOLUTION:
解决方案:
Error magically gone after 2 things:
错误在两件事之后神奇地消失了:
I imported this project into eclipse and run JUNit test from eclipse. Then I returned to IDEA and deleted all Eclipse specific files.
I synchronized my project (File->Synchronize).
我将这个项目导入到 eclipse 中并从 eclipse 运行 JUNit 测试。然后我返回到 IDEA 并删除了所有 Eclipse 特定文件。
我同步了我的项目(文件-> 同步)。
I don't know what actually was the solution of problem, but for suggestions I accept @SeanLandsman's answer
我不知道问题的实际解决方案是什么,但对于建议,我接受@SeanLandsman 的回答
回答by CJDownUnder
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.
如果您使用的是运行配置,请确保在“运行/调试配置”对话框的“启动前”部分中添加了“构建”。它似乎有时会从此对话框中删除,即使您已将其添加到默认设置中。
回答by sahanashivu
Try deleting .class file of class where nosuchmethod error is throwing, and recompile.
尝试删除抛出 nosuchmethod 错误的类的 .class 文件,然后重新编译。
回答by Arunraj Nair
Deleting the entire content of the classes dir worked for me
删除类目录的全部内容对我有用
回答by Viveksuriyan
This worked for me.
这对我有用。
In IntelliJ IDEA,
在 IntelliJ IDEA 中,
- Right click on the project.
- Select Git -> Show History.
- Opens "Version Control"
- 右键单击项目。
- 选择 Git -> 显示历史记录。
- 打开“版本控制”
Then you can navigate to Local Changes Tab.
然后您可以导航到本地更改选项卡。
回答by Dirk
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!
就我而言,这解决了这种奇怪的行为!