eclipse 配置 Maven 2 POM Editor 以源模式打开 pom.xml 文件

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

Configuring Maven 2 POM Editor to open pom.xml files in source mode

eclipsemaven-2

提问by tputkonen

I use the Maven 2 POM Editor mainly for editing POM XML files directly. Is there a way to make the editor always open files in the "Source" tab?

我使用 Maven 2 POM Editor 主要用于直接编辑 POM XML 文件。有没有办法让编辑器始终在“源”选项卡中打开文件?

回答by Jherico

In the Eclipse preferences for the Maven plugin, there is a check box for Open XML page in the POM editor by default. Its exact location varies by plugin version.

在 Maven 插件的 Eclipse 首选项中,有一个复选框用于Open XML page in the POM editor by default. 它的确切位置因插件版本而异。

Juno/Kepler/Luna/Mars (4.x)

朱诺/开普勒/月神/火星 (4.x)

In these versions of Eclipse:

在这些版本的 Eclipse 中:

  1. Click Window → Preferences
  2. Expand Maven
  3. Click User Interface
  4. Check Open XML page in the POM editor by default
  5. Click Apply and Close
  1. 单击窗口 → 首选项
  2. 展开Maven
  3. 单击用户界面
  4. 默认在 POM 编辑器中勾选Open XML 页面
  5. 单击应用并关闭

POMs will open in source view by default.

默认情况下,POM 将在源代码视图中打开。

Helios/Indigo (3.x)

赫利俄斯/靛蓝 (3.x)

In these versions of Eclipse:

在这些版本的 Eclipse 中:

Maven> POM Editor

Maven> POM Editor

回答by William T. Mallard

Like Damien suspected, myWindow>Preferences>Maven>User Interfaceoption to open POMs in the Maven POM editor automatically was indeed broken. Here's how I fixed it (Juno):

就像 Damien 怀疑的那样,我Window>Preferences>Maven>User Interface在 Maven POM 编辑器中自动打开 POM 的选项确实被破坏了。这是我修复它的方法(朱诺):

Open Window>Preferences>General>Editors>File Associations. In the upper right area click Add..., type "pom.xml", then OK.

打开Window>Preferences>General>Editors>File Associations。在右上角区域单击添加...,键入“pom.xml”,然后单击确定。

Then click on the new entry pom.xml in the upper list, and in the lower list click on Maven POM Editor, then click the Default button on the right.

然后点击上方列表中的新条目 pom.xml,在下方列表中点击 Maven POM Editor,然后点击右侧的 Default 按钮。

Click OK and then double click your pom.xml file in project explorer and it should open in the Maven POM editor.

单击“确定”,然后在项目资源管理器中双击您的 pom.xml 文件,它应该会在 Maven POM 编辑器中打开。

Bonus: The Ctrl+Shift+Fformatting does a sweet job of formatting POMs in the Maven editor. The default XML editor's formatting is pretty bad for POMs, which have attribute-free tags.

奖励:Ctrl+Shift+F格式在 Maven 编辑器中格式化 POM 的工作非常出色。默认的 XML 编辑器的格式对于 POM 来说非常糟糕,因为 POM 具有无属性标签。

回答by Luiz Feij?o Veronesi

Eclipse Juno / Mars:

日食朱诺/火星

Go to Window > Preferences > Maven > User Interface

转到窗口 > 首选项 > Maven > 用户界面

Check Open XML page in the POM editor by default

默认在 POM 编辑器中勾选 Open XML 页面

回答by Damien MIRAS

In eclipse indigo preferences>Maven>User Interface there is a check box for Open XML page in the POM editor by default". Uncheck it. (The feature can be broken as it is on my eclipse)

在 eclipse indigo 首选项>Maven>用户界面中,默认情况下在 POM 编辑器中有一个 Open XML 页面的复选框“。取消选中它。(该功能可能会在我的 eclipse 上被破坏)

回答by N Dev

Checking the check box "Open XML page in the POM editor by default" will open the POM editor but this will not automatically select the second tab - "Source". You still have to click at the bottom on the "Source" tab. By default, the POM editor opens the first tab - "Design". The POM editor will remember the last tab you clicked, so if you clicked on Source the second time you open it it will show the Source tab.

选中复选框“默认在 POM 编辑器中打开 XML 页面”将打开 POM 编辑器,但这不会自动选择第二个选项卡 - “源”。您仍然需要单击底部的“源”选项卡。默认情况下,POM 编辑器打开第一个选项卡——“设计”。POM 编辑器将记住您单击的最后一个选项卡,因此如果您在第二次打开它时单击 Source,它将显示 Source 选项卡。

Eclipse Version: Oxygen.3a Release (4.7.3a) Build id: 20180405-1200 , ubuntu 16.04

Eclipse 版本:Oxygen.3a 版本 (4.7.3a) 版本号:20180405-1200,ubuntu 16.04