eclipse 移动包日食
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6163452/
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
Moving packages eclipse
提问by Darth Blue Ray
Maybe a stupid question but I have two packages in eclipse and now I would like to move the one package into the other for better structure.
也许是一个愚蠢的问题,但我在 eclipse 中有两个包,现在我想将一个包移动到另一个包中以获得更好的结构。
Now I tried move but that generates a copy into the same package.
现在我尝试移动,但这会生成一个副本到同一个包中。
And with refactoring -> move I even can't select the packages
通过重构 -> 移动我什至无法选择包
Can anyone help me....
谁能帮我....
thx all
谢谢大家
回答by Bozho
If you have com.company.foo
and com.company.bar
, and want to move foo
into bar
, then just rename com.company.foo
to com.company.bar.foo
.
如果您有com.company.foo
和com.company.bar
,并且想要foo
进入bar
,那么只需重命名com.company.foo
为com.company.bar.foo
.
If you package happens to have subpackages, tick Rename subpackages
to move the subpackages as well.
如果您的包碰巧有子包,请勾选Rename subpackages
移动子包。
回答by saurabh
Use the package explorer view and rename the package. It asks for renaming updating references, renaming sub packages, update textual references in comments and and also non-Java text files. Click on the preview and then ok.
使用包资源管理器视图并重命名包。它要求重命名更新引用、重命名子包、更新注释和非 Java 文本文件中的文本引用。单击预览,然后确定。
回答by Huy Than
I have found the solution, when you rename a package to the desired destination, check on the box "rename subpackages" and there you go! :) – user1525788 Jul 10 at 9:14
我找到了解决方案,当您将包重命名为所需的目的地时,选中“重命名子包”框,然后就可以了!:) – user1525788 7 月 10 日 9:14
回答by Ebony Maw
This is slightly non-intuitive, but the best way to do it is by right clicking on the package you wish to move, clicking on refactor
, and then on rename
.
这有点不直观,但最好的方法是右键单击要移动的包,单击refactor
,然后单击rename
。
Then proceed to enter the fully qualified path which you desire.
然后继续输入您想要的完全限定路径。
For example, if you wish that a package called dog
be moved into a package called mammals
which itself is in a package called animals
you would essentially rename your dog
package to animals.mammals.dog
例如,如果你希望一个叫包dog
移动到一个叫包mammals
其本身就是一个包叫做animals
您会在实质上重新命名dog
包animals.mammals.dog
In other words, the package structure
换句话说,包结构
is represented as animals.mammals.dog
in the world of Java packages, and a renaming achieves the desired effect.
animals.mammals.dog
在 Java 包的世界中表示为,重命名可以达到预期的效果。
Please note that you mustnot try to achieve this by manually moving the folders in Windows explorer. These actions are best done using your IDE.
请注意,您必须不尝试在Windows资源管理器中手动移动文件夹来实现这一目标。这些操作最好使用您的 IDE 完成。
回答by Chirag Dhyani
if you have current package:
如果你有当前的包:
- com.insect.fly
- 飞虫
and would like to add subpackage to it, then renaming will solve the purpose e.g.
并想向其中添加子包,然后重命名将解决目的,例如
- com.insect.fly.mosquitto
- 飞蚊子
However, eclipse do not should it in nested style. Just do Package Explorer > click on v button on the pane next to minimize > package presentation > Hierarchical
但是,eclipse 不应该采用嵌套样式。只需执行包资源管理器 > 单击窗格上的 v 按钮以最小化 > 包演示 > 分层
Hope that SOLVES !!
希望能解决!!
回答by Ismaeel
this is rlly old but try opening in hierarchy mode. in project explorer click the small arrow (pointing down) > package presentation > hierarchical.
这是 rlly 旧但尝试在层次结构模式下打开。 in project explorer click the small arrow (pointing down) > package presentation > hierarchical.