2012-07-02 67 views
0

我在eclipse helios中使用jsf2 hibernate 4.1.4,spring 3.1和maven 3。但是當我嘗試在POM中添加依賴時,出現此錯誤。Java編譯器級別不匹配

Java compiler level does not match the version of the installed Java project facet. 

這是什麼意思?我該如何解決這個錯誤?

我也有這樣的警告:

Build path specifies execution environment J2SE-1.5. There are no JREs installed in the workspace that are strictly compatible with this environment. 

我POM:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>com.integrate</groupId> 
    <artifactId>integrate</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <name>integrate</name> 
    <dependencyManagement> 
    <dependencies> 
    </dependencies> 
    </dependencyManagement> 
    <properties> 
    <spring.version>3.1.0.RELEASE</spring.version> 
</properties> 

<dependencies> 

    <!-- Spring 3 dependencies --> 
    <dependency> 
    <groupId>org.springframework</groupId> 
    <artifactId>spring-core</artifactId> 
    <version>${spring.version}</version> 
    </dependency> 

    <dependency> 
    <groupId>org.springframework</groupId> 
    <artifactId>spring-context</artifactId> 
    <version>${spring.version}</version> 
    </dependency> 

    <dependency> 
    <groupId>org.springframework</groupId> 
    <artifactId>spring-web</artifactId> 
    <version>${spring.version}</version> 
    </dependency> 

    <dependency> 
    <groupId>org.springframework</groupId> 
    <artifactId>spring-tx</artifactId> 
    <version>${spring.version}</version> 
    </dependency> 

    <dependency> 
    <groupId>org.springframework</groupId> 
    <artifactId>spring-orm</artifactId> 
    <version>${spring.version}</version> 
    </dependency> 

    <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-test</artifactId> 
      <version>${spring.version}</version> 
     </dependency> 

    <!-- JSF dependencies --> 
    <dependency> 
    <groupId>com.sun.faces</groupId> 
    <artifactId>jsf-api</artifactId> 
    <version>2.1.6</version> 
    </dependency> 

    <dependency> 
    <groupId>com.sun.faces</groupId> 
    <artifactId>jsf-impl</artifactId> 
    <version>2.1.6</version> 
    </dependency> 

    <dependency> 
    <groupId>javax.servlet</groupId> 
    <artifactId>jstl</artifactId> 
    <version>1.2</version> 
    </dependency> 


    <!-- Hibernate dependencies --> 
    <dependency> 
    <groupId>org.hibernate</groupId> 
    <artifactId>hibernate-core</artifactId> 
    <version>4.1.4.Final</version> 
    </dependency> 

    <dependency> 
    <groupId>javassist</groupId> 
    <artifactId>javassist</artifactId> 
    <version>3.12.1.GA</version> 
    </dependency> 

    <!-- oracle Connector dependency --> 
    <dependency> 
    <groupId>com.oracle</groupId> 
    <artifactId>ojdbc6</artifactId> 
    <version>11.2.0.3</version> 
</dependency> 
<!-- c3p0 dependency --> 
     <dependency> 
     <groupId>c3p0</groupId> 
     <artifactId>c3p0</artifactId> 
     <version>0.9.1.2</version> 
    </dependency> 


</dependencies> 

的PIC: enter image description here

+0

發表您的pom.xml或使用在github –

+0

您需要粘貼垃圾桶或要點給它一個鏈接JDK 1.5安裝和設置優先 - > jre –

+0

@ J-16SDiZ,我安裝了jdk 1.6 – samira

回答

1

剛剛與Maven的編譯器插件到你的pom.xml添加構建部分。

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>2.3.2</version> 
      <configuration> 
       <source>1.6</source> 
       <target>1.6</target> 
       <encoding>UTF-8</encoding> 
      </configuration> 
     </plugin> 
    </plugins> 
</build> 

然後你應該配置項目的構建路徑。您可以從eclipse工作區中刪除項目(不從文件系統中刪除),從項目中刪除eclipse的設置(.project,.classpath和.settings文件和文件夾),並重新導入您的項目作爲存在Maven項目到您的IDE。 Eclipse將正確地重新生成其設置。

+0

我添加了這些代碼,但它沒有解決。 – samira

+0

我上面編輯了我的評論。請檢查您的pom.xml的一致性,在您的項目的根目錄下運行'mvn clean compile'。如果沒關係,你可以選擇一個合適的案例來配置你的項目類路徑設置,或者刪除上述註釋中提到的eclipse設置。 –

0

請檢查涉及您的項目的項目面(右擊項目/ Properties/Project Facets/Java)。

這只是在您的系統中安裝的Java版本和您在項目的項目構面中指定的版本可能不匹配。

+0

in priject facet java version is 1.6 – samira

+0

那麼它是否已經安裝在您的系統中? –

+0

我在我的系統中安裝了jdk 7u1 – samira

0

指定d對Maven的Java版本:\的maven-2.2.1 \ CONF toolchains.xml

<?xml version="1.0" encoding="UTF-8"?> 
<toolchains> 
<toolchain> 
    <type>jdk</type> 
    <provides> 
     <version>1.5</version> <!--This should be same as is configured via the toolchains plugin --> 
     <vendor>ibm</vendor> <!--This should be same as is configured via the toolchains plugin --> 
    </provides> 
    <configuration> 
     <jdkHome>C:\Program Files\Java\jdk1.5.0</jdkHome> 
    </configuration> 
</toolchain> 
</toolchains> 
相關問題