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

我使用 Maven2POM 编辑器主要是为了直接编辑 POMXML 文件。是否有办法使编辑器总是在“源”选项卡中打开文件?

30196 次浏览

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.

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

In these versions of 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

POMs will open in source view by default.

Helios/Indigo (3.x)

In these versions of Eclipse:

Maven > POM Editor

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)

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

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

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.

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

Bonus: The Ctrl+Shift+F formatting 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.

Eclipse Juno / Mars:

Go to Window > Preferences > Maven > User Interface

Check Open XML page in the POM editor by default

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.

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