2010-02-10 54 views
67

Eclipse的 「問題」 選項卡顯示此錯誤:「刻面工程Prblem(Java版本不匹配)」 錯誤消息

Description: Java compiler level does not match the version of the installed Java project facet.
Resource: groupping
Path: [blank]
Location: Unknown
Type: Faceted Project Problem (Java Version Mismatch)

pom.xml有此設置:

<plugins> 
    <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-compiler-plugin</artifactId> 
     <configuration> 
      <source>1.6</source> 
      <target>1.6</target> 
     </configuration> 
    </plugin> 
</plugins> 

還能在哪裏設置不匹配?

回答

136

您是否檢查了您的Project Properties -> Project Facets面板? (從that post

A WTP project is composed of multiple units of functionality (known as facets).

The Java facet version needs to always match the java compiler compliance level.
The best way to change java level is to use the Project Facets properties panel as that will update both places at the same time.

WTP

The " Project->Preferences->Project Facets " stores its configuration in this file, " org.eclipse.wst.common.project.facet.core.xml ", under the " .settings " directory.

The content might look like this

<?xml version="1.0" encoding="UTF-8"?> 
<faceted-project> 
    <runtime name="WebSphere Application Server v6.1"/> 
    <fixed facet="jst.java"/> 
    <fixed facet="jst.web"/> 
    <installed facet="jst.java" version="5.0"/> 
    <installed facet="jst.web" version="2.4"/> 
    <installed facet="jsf.ibm" version="7.0"/> 
    <installed facet="jsf.base" version="7.0"/> 
    <installed facet="web.jstl" version="1.1"/> 
</faceted-project> 

檢查還您Java compliance level

Java compliance level

+4

你是我的英雄。 – Ricardo 2014-02-26 22:40:44

+0

非常感謝!它幫助 – priyanka 2017-10-11 08:11:55

40

You have two options to fix the issue:

1- Manually make sure the two versions match.
2- Use the IDE's help as follows:
- Right mouse click on the error in the 'Problems' view
- Select the 'Quick Fix' menu item from the pop-up menu
- Select the right compiler level in the provided dialog and click 'Finish'.

來自Eclipse: Java compiler level and project facet mismatch

此外還給出了可以訪問Java編譯器和構面版本的位置。

+0

快速修復爲我工作,謝謝! – Jos 2016-10-12 13:49:17

20

項目構面應該由POM配置中的M2Eclipse插件自動導出。如果您對POM進行了一些更改並需要Eclipse將它們考慮在內,右鍵單擊項目上的,然後轉至Maven>更新項目配置。您不應該手動設置項目構面。

+1

那裏有趣的評論。 +1 – VonC 2010-02-10 21:50:47

+0

@VonC當然你可以正確的手動配置它,但是當使用maven和m2eclipse插件時,插件應該 - 而且實際上 - 爲你配置這個。所有需要的元數據都在POM:JDK級版本,Servlet API等中。開發人員在導入或任何其他POM更新後不必手動設置,這是一件好事。這也適用於maven-eclipse-plugin(基於POM元數據生成構面)。 – 2010-02-10 22:01:16

+0

這可能是你編寫它的時候,但最新版本的m2e截至2011-05不像舊版本那樣手動添加依賴關係,所以你必須手動將項目轉換爲分面項目,然後手動編輯配置文件將正確的jar文件複製到lib目錄中。這是一個痛苦。請參閱https://sites.google.com/site/michaelvorburger/m2e-and-wtp – 2011-05-08 15:48:08

0

在春天STS,右鍵單擊項目&選擇「打開項目」,這一規定做背景&必要的行動,使項目恢復工作空間。

感謝&問候 Vengat馬蘭