为什么当我在 Eclipse 中重命名项目时,Tomcat 没有选择新的资源名称?

发布于 2024-08-19 23:56:08 字数 191 浏览 2 评论 0原文

我做了重构>在我的工作区中的一个项目上重命名,但是当我进入服务器选项卡并右键单击>为我的Tomcat服务器添加和删除以便修改服务器上配置的资源,我的项目的资源名称是我的旧项目名称。我到处寻找尝试更改此设置,例如某种 Tomcat 配置文件或设置,但我在任何地方都找不到它。因此,我的项目被命名为一件事,但在服务器上以不同的名称配置为资源。我该如何改变这个?

I did refactor > rename on a project in my workspace, but then when I went under the servers tab and did a right-click > Add and Remove for my Tomcat server in order to modify the resources configured on the server, the resource name for my project is my old project name. I looked everywhere to try and change this, like some sort of Tomcat config file or setting, but I can't find it anywhere. So my project is named one thing, but is configured as a resource on the server under a different name. How do I change this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

三月梨花 2024-08-26 23:56:08

我相信您正在寻找位于 your project/.settings/org.eclipse.wst.common.component 下的隐藏首选项。

文件的开头应大致如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
    <wb-module deploy-name="projectB">

因此只需更改部署名称即可。我建议更改的另一件事是项目的上下文根,右键单击项目 ->属性->网络项目设置。

(只是澄清一下,据我所知,这种行为是 WTP 中的一个错误。WTP 负责维护 .settings 下隐藏的 pref 文件,并且在项目重命名时它只是不更新​​该文件)

I believe you are looking for a hidden pref located under your project/.settings/org.eclipse.wst.common.component.

The beginning of the file should look roughly like this:

<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
    <wb-module deploy-name="projectB">

So just change the deploy-name. Another thing that I recommend changing is the project's context root, right-click the project -> Properties -> Web Project Settings.

(just to clarify, to the best of my understanding this behavior is a bug in WTP. WTP is responsible for maintaining the hidden pref file under .settings, and it just doesn't update the file when the project is renamed)

前事休说 2024-08-26 23:56:08

在这里编辑您的项目名称:

Eclipse ->项目->属性-> Web 项目设置 -> Context Root

这是您想要编辑项目名称的地方(也),我相信它也会更改 project/.settings/org.eclipse.wst.common.component 文件正如上面 Yoni 的回答中提到的。我建议打开它来验证它。如果是这样,我相信这是更好的答案。

编辑:任何验证这一点的人,请发帖,我会将您的验证附加到我的答案中。

2023 年 3 月更新:

请参阅 Tom Rutchik 的回复和 smat88dd 的答案。 Tom 详细说明了此方法不会更改 org.eclipse.wst.common.component 文件中的“wb-module deploy-name”或属性“java-output-path”。 smat88dd 手动编辑 org.eclipse.wst.common.component 文件的答案可能就是答案。

Edit your project name here:

Eclipse -> Project -> Properties -> Web Project Settings -> Context Root

This is where you want to edit the project name (too), and I believe it will also change the project/.settings/org.eclipse.wst.common.component file as mentioned in Yoni's answer above. I would recommend opening it to verify it though. If so, this is the better answer I believe.

EDIT: Anyone who verifies this, please post, and I'll append your verification to my answer.

2023-MAR UPDATE:

See both Tom Rutchik's reply and smat88dd's answer. Tom details this method does not change the "wb-module deploy-name" nor the property "java-output-path" in the org.eclipse.wst.common.component file. And smat88dd's answer of editting the org.eclipse.wst.common.component file manually may be the answer.

£烟消云散 2024-08-26 23:56:08

不幸的是,更改上下文根不会更新 org.eclipse.wst.common.component 文件。所以确实有必要更改文件中的部署名称。

Unfortunately, changing the Context Root does not update the org.eclipse.wst.common.component-file. So it is really necessary to change the deploy name in the file.

少女七分熟 2024-08-26 23:56:08

回复 Xonatron 的消息:
更改上下文根只会更改访问应用程序所请求的 URL。
要更改 Eclipse 中显示的“资源名称”,您必须手动更新文件 project/.settings/org.eclipse.wst.common.component 并刷新 Eclipse 项目 (F5)。

Answering Xonatron's message:
changing the context root only changes the URL requested to reach the app.
To change the 'resource name' as displayed in Eclipse you have to manually update the file project/.settings/org.eclipse.wst.common.component AND refresh the Eclipse project (F5).

夏至、离别 2024-08-26 23:56:08

其他答案没有解决我的问题。删除然后重新创建我的 tomcat 服务器有效。如果您仍然遇到问题,请从基于 UNIX 的终端运行此命令。

grep -Ril 'yourOldProjectName' 'C:\EclipseWorkspace\yourProjectsDir'

这将在整个项目中查找旧项目名称。输出是具有旧项目名称的所有文件的文件名。

The other answers didn't fix my issue. Deleting and then recreating my tomcat server worked. If you're still having issues run this command from a unix based terminal.

grep -Ril 'yourOldProjectName' 'C:\EclipseWorkspace\yourProjectsDir'

This will look through your entire project for your old project name. The output is the file names of all the files that have your old project name.

椒妓 2024-08-26 23:56:08

同样的问题,并通过手动更改 project/.settings/org.eclipse.wst.common.component 文件中的 deploy-name 并编辑上下文根解决了该问题em> 在 Eclipse ->项目->属性-> Web 项目设置 ->上下文根。自从我做了这个技巧以来,我还没有遇到过这个问题。

Same issue and resolved it by changing manually deploy-name in project/.settings/org.eclipse.wst.common.component file and editing Context root in Eclipse -> Project -> Properties -> Web Project Settings -> Context Root. I have not encountered the issue since I did the trick.

云归处 2024-08-26 23:56:08

在@Yoni 帖子中添加了图像和一些信息。


Eclipse tomcat 添加删除仍然显示旧项目名称。 错误 180741

文件:D:\Yashwanth\MyProject.settings\org.eclipse.wst.common.component
Tomcat:MyProject(MyOldProject)

<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
    <wb-module deploy-name="MyOldProject">
        <property name="context-root" value="MyProject"/>
        <!-- ... -->
    </wb-module>
</project-modules>

从 Eclipse 添加资源时的样子。

输入图片此处的说明

要解决此问题,请将 deploy-name="MyOldProject" 更改为 deploy-name="MyProject"。更改后,您将在 Tomcat 中看到 MyProject

Added images and some information to @Yoni post.


Eclipse tomcat Add Remove still shows old project name. Bug 180741

File: D:\Yashwanth\MyProject.settings\org.eclipse.wst.common.component
Tomcat: MyProject(MyOldProject)

<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
    <wb-module deploy-name="MyOldProject">
        <property name="context-root" value="MyProject"/>
        <!-- ... -->
    </wb-module>
</project-modules>

How it looks like when you add a resource from eclipse.

enter image description here

To resolve the issue change from deploy-name="MyOldProject" to deploy-name="MyProject". After changing you will see in Tomcat as MyProject

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文