自动格式化 pom.xml 而不使用 m2eclipse 插件

发布于 2024-09-02 07:03:56 字数 365 浏览 1 评论 0原文

我在 Eclipse 中开发时不使用 Eclipse maven 插件。

我使用以下命令在外部生成 Eclipse 类路径:

mvn eclipse:eclipse

这已经运行良好一段时间了,我不倾向于添加 Maven 插件。

但是,我希望能够“自动格式化”我的 pom.xml 文件。

我的 pom.xml 没有显示为“源”文件,因此上下文“源”菜单没有显示。

Control-Shift-F 也不起作用。

有没有办法在不安装 m2eclipse 插件的情况下做到这一点?是否有其他通用的“XML 编辑器”插件可以帮助解决此问题?

I don't use the Eclipse maven plugin while developing in Eclipse.

I generate my Eclipse classpath externally using the following command:

mvn eclipse:eclipse

This has worked fine for quite some time and I am not inclined to add a maven plugin.

However, I would like to be able to "autoformat" my pom.xml file.

My pom.xml is not showing up as a "Source" file and therefore the contextual "Source" menu doesn't show up.

Control-Shift-F doesn't work either.

Is there a way to do this without installing the m2eclipse plugin? Is there any other generic "XML Editor" plugin that can help with this?

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

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

发布评论

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

评论(4

看轻我的陪伴 2024-09-09 07:04:06

仅当我们在文本编辑器中打开时才会出现此问题。当我们在 xml 编辑器中打开 pom.xml 并使用快捷键 shft+ctl+F 时,解决方案有效

This problem occurs only when we open in text editor. Solution works when we open the pom.xml in xml editor and use the short cut commands as shft+ctl+F

饮湿 2024-09-09 07:04:04

同时使用 ctrl + shift + F 键,对我来说,笔记本电脑的 ctrl + shift 组合键左侧不起作用,我尝试使用右侧组合键,但它有效。

Use ctrl + shift + F keys together, for me left side of ctrl + shift key combination of laptop did't work I tried with right side combination and it worked.

七七 2024-09-09 07:04:02

所以,我找到了一种方法 -

  1. 选择 pom.xml 的源(ctrl+A)。
  2. 单击鼠标右键。
  3. 然后单击来源>清理文档。
  4. 在弹出窗口中选中“格式源”并取消选中所有其他选项。

完成了! :)

So, I found a way -

  1. Select source of pom.xml (ctrl+A).
  2. Click right button of mouse.
  3. Then click Source > Cleanup Document.
  4. Check "Format Source" in popup and uncheck all other options.

it's Done!! :)

a√萤火虫的光℡ 2024-09-09 07:04:01

我可能遗漏了一些明显的东西,但为什么不使用 Eclipse 的内置 XML 编辑器 它支持格式化(通过常规 Shift+Ctrl +F)?

I may be missing something obvious but why don't you use Eclipse's built-in XML Editor which supports formatting (via the regular Shift+Ctrl+F)?

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