Java编译器级别不匹配

标签 java eclipse jakarta-ee maven maven-3

我在 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>

图片: enter image description here

最佳答案

只需将 build 部分和 ma​​ven-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 将正确重新生成其设置。

关于Java编译器级别不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11291727/

相关文章:

eclipse - 调用层次结构和查找引用 eclipse 有什么区别?

java - spring mvc中如何获取方法请求

java - scala.collection.Seq 不适用于 Java

Android Facebook SDK 示例 : 'your project Contains error(s), please fix them before running your application'

java - 出现构建错误,但程序仍然完美运行

java - 使用非数据库字段自定义 Liferay Web 服务响应

java - 如何获取字符串中的单词?

java - 将 JTextField 替换为 Java Swing 中的一行

Java和xpath - xHtml解析问题

java - Jersey 多个可以在同一路径上获得响应吗?