简体   繁体   English

Eclipse-重命名软件包摆脱了一堆东西,有没有办法恢复它?

[英]Eclipse - renaming a package got rid of a bunch of stuff, is there a way to recover it?

So I made a package, lets call it dev.example.project for example purposes. 因此,我制作了一个包,出于示例目的,将其dev.example.project all my other packages extended off of that one, with names like dev.example.project.handler or dev.example.project.assets . 我所有其他软件包都从那个软件包扩展dev.example.project.handler ,其名称类似于dev.example.project.handlerdev.example.project.assets But I decided to go back and change the dev.example.project package's name to something else, like dev.betterexample.project . 但是我决定回去将dev.example.project包的名称更改为其他名称,例如dev.betterexample.project

I thought it would be a simple matter of renaming all the other packages and import statements so no errors would happen, but right after i changed the name, all the packages in my project turned white and became inaccessible. 我认为重命名所有其他软件包和import语句很简单,因此不会发生任何错误,但是在我更改名称之后,项目中的所有软件包都变成了白色,无法访问。 I changed the name back to what it originally was, but when i opened Eclipse again, some packages and files were simply not there. 我将名称改回了原来的名称,但是当我再次打开Eclipse时,根本没有某些软件包和文件。

I spent a lot of time on this project, someone help? 我在这个项目上花了很多时间,有人帮忙吗?

Depending how exactly you did that renaming, various things could have gone wrong. 根据您重命名的精确程度,各种错误可能会出错。

Remember: you can always go in and work outside of eclipse. 切记:您总是可以在日食之外工作。 Close it, open a file explorer and create directories that use the names you want to use. 关闭它,打开文件浏览器并创建使用您要使用的名称的目录。 Then move files manually to their target directories. 然后将文件手动移动到其目标目录。 If you want to, open them in another text editor and fix the package lines. 如果需要,请在另一个文本编辑器中将其打开,然后修复打包行。 When you now open eclipse, do a refresh and full rebuild. 现在打开eclipse时,请刷新并完全重建。 Things should be fine then. 那事情就好了。

That is probably not the most elegant solution, but it always works. 那可能不是最优雅的解决方案,但它始终有效。 And more importantly, you are in full control of everything that happens! 更重要的是,您完全可以控制发生的一切!

And for the record: the real answer to avoid catastrophic loss of code is to use a source code management system such as git. 并记录在案:避免灾难性代码丢失的真正答案是使用诸如git之类的源代码管理系统。 And to then push your changes constantly out to that "backup" facility. 然后将您的更改不断推送到该“备份”工具。

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

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