【发布时间】: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