Eclipse就好像选择了编译器< 1.5一样,但设置了1.7

时间:2015-10-09 11:12:07

标签: java eclipse sts-springsourcetoolsuite

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

image description

图书馆也是最新的:

image description

另一件事是我使用Ant来构建,并且它构建项目没有错误,尽管整个项目树是红色表示问题:

image description

但是,在构建之后,项目无法正常工作,我会遇到如下错误:

[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来构建它,我不是项目作者。到目前为止,所有版本都有效。

3 个答案:

答案 0 :(得分:1)

请尝试以下操作:右键单击项目>构建路径>配置Build Path,然后在Libraries选项卡上单击JRE System Library并单击Edit按钮。

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

希望这有帮助。

答案 1 :(得分:0)

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

此外,在执行此操作后,转到Java - >安装的JRE' s>执行Envirionments并将正确的jdk&s / jre与执行环境对齐!

答案 2 :(得分:0)

Double restart解决了这个问题 - Eclipse很奇怪。