Java 如何在STS中导入spring项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28507487/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 06:20:58  来源:igfitidea点击:

How to import a spring project in STS

javaeclipsespringspring-tool-suite

提问by

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

并且完成按钮和下一步按钮处于禁用状态。请帮助我

回答by Micha? Szyd?owski

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 .metadatafolder or create a new workspace.

确保它真的不在工作区中,如果没有任何其他同名的项目也是如此。如果没有,只需删除该.metadata文件夹或创建一个新的工作区。

回答by ConfusedCoder

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'. So, the project may be still there in the workspace folder though its deleted in STS.

检查磁盘上工作区的文件夹中是否还有项目。您可能已在 STS 中删除,而未选中“在磁盘上删除”。因此,尽管在 STS 中删除了该项目,但该项目可能仍在工作区文件夹中。

回答by Dan Hargis

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!

祝你好运!

回答by Martin Lippert

The workspace in STS/Eclipse is not automatically the same as the file structure that you have on disc in your workspace directory. You can have projects in this workspace folder or somewhere else on disc.

STS/Eclipse 中的工作区不会自动与磁盘上工作区目录中的文件结构相同。您可以在此工作区文件夹或光盘上的其他位置拥有项目。

To get them into your project explorer (and access them from inside STS/Eclipse), you need to import them (Import Existing Projects into Workspace). 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.

要将它们放入您的项目资源管理器(并从 STS/Eclipse 内部访问它们),您需要导入它们(将现有项目导入工作区)。然后您可以选择这些项目所在的文件夹。如果您在光盘上的工作区文件夹中已经有这些项目,您可以在向导中选择工作区文件夹作为根文件夹。它将显示该文件夹中光盘上存在的所有项目,并将已在 Eclipse 工作区中导入/引用的项目灰显。

回答by Kris

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 文件中导入您的项目。

回答by himanshu bisht

Generally this kind of problems not occurred you can go to Project option and clean and than restart STS. May be STS is not synched with the latest configured project.

一般不会出现此类问题,您可以转到项目选项并清除并重新启动 STS。可能是 STS 与最新配置的项目不同步。

回答by Kostantsa

the problem is that when you delete a project maybe sts only close it. Try View Menu --> uncheck closed projects Now you will see all closed project, simply delete it.

问题是当你删除一个项目时,sts 可能只会关闭它。尝试查看菜单 --> 取消选中已关闭的项目 现在您将看到所有已关闭的项目,只需将其删除即可。

回答by Abhishek Ejam

When you launch Spring Tools Suite, it will ask you to Select directory as workspaceas below:

当您启动 Spring Tools Suite 时,它​​会要求您选择目录作为工作区,如下所示:

spring tools suite launcher

spring tools suite launcher

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

It solved my problem. Hope it helps..

它解决了我的问题。希望能帮助到你..

Happy Coding!!

快乐编码!!