简体   繁体   English

如何在Eclipse中自动修复“已声明的软件包不匹配……”错误?

[英]How do I autofix “The declared package does not match…” errors in Eclipse?

I have a number of Java files in Eclipse that currently have the wrong package at the top of them. 我在Eclipse中有许多Java文件,这些文件的顶部目前有错误的软件包。 They are in the correct directory, however. 但是,它们在正确的目录中。 I would like to fix all of the errors at once (read: not manually). 我想一次修复所有错误(阅读:不手动)。

I have tried the following: 我尝试了以下方法:

  • If I go to the Problems view and try to Quick Fix, I can only do one at a time. 如果进入“问题”视图并尝试快速修复,则一次只能执行一项操作。 If I select some subset and try to quick fix (all with the "The declared package" error), it states that they have nothing in common. 如果我选择一些子集并尝试快速修复(均出现“声明的软件包”错误),则表明它们没有任何共同之处。

  • I have also tried to use Source -> Clean Up but it doesn't fix my errors either. 我也曾尝试使用Source-> Clean Up,但是它也不能解决我的错误。

  • My last hope is Search and Replace, but I would really like something a bit more automatic. 我最后的希望是“搜索和替换”,但我真的希望有一些自动的东西。

It looks like there is an answer here: 似乎这里有一个答案:

Eclipse - How to "Change package declaration to ...." across an entire project Eclipse-如何在整个项目中“将包声明更改为....”

And to quote from the answer: 并引用答案:

"Unfortunately there is no option to fix the issue across multiple units at one go; you will have to apply the quick fix for every problem." “不幸的是,无法一次性解决跨多个部门的问题;您将必须针对每个问题应用快速修复。”

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

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