【问题标题】:Eclipse acts as if compiler <1.5 was selected, though 1.7 is setEclipse 的行为就像选择了编译器 <1.5,但设置了 1.7
【发布时间】:2015-10-09 11:12:07
【问题描述】:

我刚好遇到enum cannot be resolved to a type 错误,解决方法是described in this answer。但问题是我选择了源级别1.7,所以提到的答案并没有真正帮助我:

库也是最新的:

还有一件事是我使用Ant构建,它构建项目没有错误,虽然整个项目树都是红色的,表明有问题:

但是,项目建好后就不行了,出现这样的错误:

[ERROR] 2015-10-08 04:01:56,946 org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateDAO' defined in ServletContext resource [/WEB-INF/hibernate-persistance.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [cz.techsys.web.server.services.hibernatepersistance.HibernateDAO]: Constructor threw exception; nested exception is java.lang.Error: Unresolved compilation problems: 
    Syntax error, annotations are only available if source level is 1.5 or greater
    Type mismatch: cannot convert from Object to PersistSession
    Syntax error, annotations are only available if source level is 1.5 or greater
    Syntax error, parameterized types are only available if source level is 1.5 or greater
    Type mismatch: cannot convert from Object to History
    Type mismatch: cannot convert from Object to LoginPersistance
    Syntax error, parameterized types are only available if source level is 1.5 or greater

像往常一样使用 Eclipse,我并没有真正改变任何东西,它改变了自己。我没有编辑项目,我只使用 IDE 来构建它,我不是项目作者。到现在为止,所有的构建都成功了。

【问题讨论】:

  • 您的项目中似乎配置了两个 JRE - JDK 1.7 和 JRE 1.8。去掉后者,它可能会混淆 Eclipse。

标签: java eclipse sts-springsourcetoolsuite


【解决方案1】:

尝试以下操作:右键单击项目 > 构建路径 > 配置构建路径,然后在库选项卡上单击 JRE 系统库并单击编辑按钮。

然后将执行环境上的系统库设置为所需的JavaSE或选择Workspace默认JRE(默认情况下是正确的)。

希望这会有所帮助。

【讨论】:

    【解决方案2】:

    在 Java 下验证 -> 已安装的 JRE。选择了正确的 JDK。

    另外,在这样做之后,转到 Java -> Installed JRE's -> Execution Envirionments 并将正确的 jdk's/jre's 与执行环境对齐!

    【讨论】:

    • 已验证。在我工作时,Eclipse 突然因内存不足错误而崩溃。之后,一切都解决了。请注意,我之前已经重新启动了 IDE,但它并没有解决问题。
    【解决方案3】:

    双重重启解决了这个问题 - Eclipse 很奇怪。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-09-29
      • 1970-01-01
      • 2011-06-23
      • 1970-01-01
      • 2015-10-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多