0

我在 eclipse helios 中使用 jsf2 hibernate 4.1.4、spring 3.1 和 maven 3。但是当我尝试将依赖项添加到 POM 时出现此错误。

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>

图片: 在此处输入图像描述

4

3 回答 3

1

只需将带有maven-compiler-plugin的构建部分添加到您的 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 将正确地重新生成其设置。

于 2012-07-02T10:30:34.253 回答
0

请检查与您的项目有关的项目方面(右键单击项目/Properties/Project Facets/Java)。

只是您在系统中安装的 java 版本与您在项目的项目方面中指定的 java 版本可能不匹配。

于 2012-07-02T10:29:28.833 回答
0

在 D:\maven-2.2.1\conf toolchains.xml 中指定 Maven 的 java 版本

<?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>
于 2012-07-02T11:48:15.980 回答