简体   繁体   English

如何在Spring Tool Suite中重命名文件

[英]How to rename file in Spring Tool Suite

In Spring Tool Suite, I have a project open and want to rename a .java file. 在Spring Tool Suite中,我打开了一个项目,并想重命名.java文件。 I click the file then File > Rename and rename the file. 我单击文件,然后单击文件>重命名并重命名该文件。 I see the file name updates in the left pane (Project Explorer) but then it quickly changes back to the old file name. 我在左窗格(项目浏览器)中看到文件名更新,但是随后它很快又变回原来的文件名。

Any one know how to accomplish this or what's wrong? 有人知道如何实现这一目标或出了什么问题?

I'm not sure what you're running into but the following works for me. 我不确定您会遇到什么,但是以下对我有用。

Step 1. 第1步。

第1步。

Step 2. 第2步。

第2步。

Step 3. 第三步

第三步

Easiest way to rename a class in eclipse: 在Eclipse中重命名类的最简单方法:

  1. Mark the class in the project explorer 在项目资源管理器中标记课程
  2. Press F2 按F2
  3. Rename as you like in the dialog box 根据需要在对话框中重命名
  4. OK

You will need to use: 您将需要使用:

1. Refactor
2. Rename

And also make sure that you change the class name 并确保您更改了类名

Open the class file you want to rename. 打开您要重命名的类文件。 In the text editor, double-click on the class name to select it. 在文本编辑器中,双击类名称以将其选中。 Now do Alt-Shift-R (or right-click on selected text and select Refactor>Rename in the context menu) and rename the class, then click Enter/Return. 现在执行Alt-Shift-R(或右键单击选定的文本,然后在上下文菜单中选择“重构”>“重命名”)并重命名该类,然后单击“输入/返回”。 The STS Refactor/Renaming wizard should take over and rename both the class and the file from there. STS重构/重命名向导应该接管并从那里重命名类和文件。

The provided answers would probably work in most cases but not for me. 提供的答案可能在大多数情况下都适用,但不适用于我。 I had to rename the file on disk, refresh the Project Explorer, which picked up the new name. 我不得不重命名磁盘上的文件,刷新Project Explorer,然后选择了新名称。 The go back on disk and rename the file to the target name, refresh PE and now all is well. 回到磁盘上,将文件重命名为目标名称,刷新PE,现在一切正常。

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

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