简体   繁体   English

如何在STS中导入spring项目

[英]How to import a spring project in STS

Just by a mistake I had deleted a spring project in STS.To use it back I borrowed the same project from my friend in zip format but when I tried to import it says只是一个错误,我在 STS 中删除了一个 spring 项目。为了使用它,我以 zip 格式从我的朋友那里借用了同一个项目,但是当我尝试导入它时说

Some projects cannot be imported because they already exist in the workspace某些项目无法导入,因为它们已存在于工作区中

Following is the way I tried to import以下是我尝试导入的方式

file->import->general->existing projects into worspace->select archive file文件->导入->常规->现有项目到worspace->选择存档文件

and after browse when I select the zip project当我选择 zip 项目时浏览

Some projects cannot be imported because they already exist in the workspace某些项目无法导入,因为它们已存在于工作区中

and the finish button and next button are in disabled state.Please help me并且完成按钮和下一步按钮处于禁用状态。请帮助我

The workspace in STS/Eclipse is not automatically the same as the file structure that you have on disc in your workspace directory. STS/Eclipse 中的工作区不会自动与磁盘上工作区目录中的文件结构相同。 You can have projects in this workspace folder or somewhere else on disc.您可以在此工作区文件夹或光盘上的其他位置拥有项目。

To get them into your project explorer (and access them from inside STS/Eclipse), you need to import them (Import Existing Projects into Workspace).要将它们放入您的项目资源管理器(并从 STS/Eclipse 内部访问它们),您需要导入它们(将现有项目导入工作区)。 Then you can select the folder where those projects are located in. In case you have those projects already in your workspace folder on disc, you can choose the workspace folder as root folder in the wizard.然后您可以选择这些项目所在的文件夹。如果您在光盘上的工作区文件夹中已经有这些项目,您可以在向导中选择工作区文件夹作为根文件夹。 It will show all the projects that exist on disc in that folder and grey those out that are already imported/referenced in your workspace in Eclipse.它将显示该文件夹中光盘上存在的所有项目,并将已在 Eclipse 工作区中导入/引用的项目灰显。

Make sure it is really not in workspace, also if there aren't any other projects with the same name.确保它真的不在工作区中,如果没有任何其他同名的项目也是如此。 If not, just delete the .metadata folder or create a new workspace.如果没有,只需删除.metadata文件夹或创建一个新工作区。

Check if you still have the project in folder of the workspace on disk.检查磁盘上工作区的文件夹中是否还有项目。 You may have deleted in STS, without checking 'Delete on disk'.您可能已在 STS 中删除,而未选中“在磁盘上删除”。 So, the project may be still there in the workspace folder though its deleted in STS.因此,尽管在 STS 中删除了该项目,但该项目可能仍在工作区文件夹中。

I get this issue from time to time.我不时遇到这个问题。 Usually I just open a new workspace but sounds like you don't want to loose other projects.通常我只是打开一个新工作区,但听起来您不想丢失其他项目。

I simply open the.project file in my project and change the name of the project in name tag.我只需在我的项目中打开 .project 文件并在名称标签中更改项目的名称。

Good Luck!祝你好运!

Probably whey you 'accidentally deleted' your project, you only deleted it from the Eclipse workspace, but not from the actual workspace folder on your hard-drive (as other people pointed out, Eclipse can arbitrarily map workspace projects to files on disk, so it is possible for a project to be 'deleted' from your Eclipse workspace but still exist on disk.可能是您“意外删除”了您的项目,您只是从 Eclipse 工作区中删除了它,而不是从硬盘驱动器上的实际工作区文件夹中删除了它(正如其他人指出的那样,Eclipse 可以任意将工作区项目映射到磁盘上的文件,所以项目可能会从 Eclipse 工作区中“删除”但仍存在于磁盘上。

The good news is the files you deleted are actually still there.好消息是您删除的文件实际上仍然存在。

Instead of importing your project from a zip, you may just want to import those files from the workspace folder back into your Eclipse workspace.您可能只想将这些文件从工作区文件夹导入回 Eclipse 工作区,而不是从 zip 文件中导入您的项目。

Generally this kind of problems not occurred you can go to Project option and clean and than restart STS.一般不会出现此类问题,您可以转到项目选项并清除并重新启动 STS。 May be STS is not synched with the latest configured project.可能是 STS 与最新配置的项目不同步。

When you launch Spring Tools Suite, it will ask you to Select directory as workspace as below:当您启动 Spring Tools Suite 时,它​​会要求您选择目录作为工作区,如下所示:

spring 工具套件启动器

If the directory you selected here (ie, workspace directory) is the same as the directory where the project that you are going to import resides, then you will get Some projects cannot be imported because they already exist in the workspace .如果您在此处选择的目录(即工作空间目录)与您要导入的项目所在的目录相同,那么您将得到一些项目无法导入,因为它们已存在于工作空间中

Therefore, to solve the issue,因此,要解决问题,

  • Close Spring Tool Suite关闭 Spring 工具套件
  • Create a new directory创建一个新目录
  • Launch Spring Tool Suite again再次启动 Spring Tool Suite
  • And, select that as your workspace并且,选择它作为您的工作区
  • Launch the application and you would be able to import as you mentioned in your question启动应用程序,您将能够按照您在问题中提到的方式进行导入

It solved my problem.它解决了我的问题。 Hope it helps..希望能帮助到你..

Happy Coding!!快乐编码!!

the problem is that when you delete a project maybe sts only close it.问题是当你删除一个项目时,sts 可能只会关闭它。 Try View Menu --> uncheck closed projects Now you will see all closed project, simply delete it.尝试查看菜单 --> 取消选中已关闭的项目 现在您将看到所有已关闭的项目,只需将其删除即可。

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

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