eclipse 在java中更改包名声明的快捷方式
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4321779/
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
Shortcut for changing package name declaration in java
提问by Jason
We have a simple java project in eclipse and we have migrated package name for an already existing source code. Is there a shortcut for changing package name declarations while you are inside the code editor
我们在 eclipse 中有一个简单的 java 项目,并且我们已经为已经存在的源代码迁移了包名。当您在代码编辑器中时,是否有更改包名称声明的快捷方式
回答by Michael Mrozek
Select the package name, and use Refactor -> Rename
(Shift+Alt+R) to open the Rename Package dialog
选择包名称,然后使用Refactor -> Rename
( Shift+Alt+R) 打开重命名包对话框
回答by drekka
Refactoring is the best way, however be wary of changing package names if your source is under version control. I've had all sorts of conflict, update issues with changing package names because of the sequence of commits done (to SVN). It does work, just can be tricky to get everything commited correctly and the repository and working directory correctly in sync.
重构是最好的方法,但是如果您的源代码受版本控制,请注意更改包名称。由于提交的顺序(到SVN),我遇到了各种各样的冲突,更新包名称的更新问题。它确实有效,只是要正确提交所有内容并使存储库和工作目录正确同步可能会很棘手。
回答by Mahendra Liya
Just select your package and press-hold the Alt-Shift-R keys. Alternatively, you can select your package, right click it and select Refactor -> Rename.
只需选择您的包并按住 Alt-Shift-R 键。或者,您可以选择您的包,右键单击它并选择重构 -> 重命名。
Hope this helps.
希望这可以帮助。
Regards, Mahendra Liya.
问候,马亨德拉莉亚。
回答by Mudassir
When you change the structure of a project, eclipse prompts you to update the references. If you allow eclipse, it will do it automatically. Now, you can perform a Find & Replace operation to manually update you package names.
当您更改项目的结构时,eclipse 会提示您更新引用。如果您允许 Eclipse,它会自动执行。现在,您可以执行查找和替换操作来手动更新您的包名称。