首页 > 解决方案 > 在 eclipse IDE 上使用本地计算机上的 Tomcat 服务器修复 eclipse 上的编译错误,我该怎么做?

问题描述

当我尝试使用 Eclipse IDE 在 Tomcat 服务器上编译本地项目时遇到问题。我正在使用 GWT 2.7.0,我的 java 版本是 1.8.301。当我在本地使用命令行编译时,它构建成功,但是当我尝试使用 eclipse 编译时,它会产生以下错误。非常感谢您的帮助,如果我不清楚我的问题是什么,我们深表歉意。

[ERROR] Errors in 'jar:file:/C:/Users/11033178/.m2/repository/de/knightsoft-net/gwt-commons-lang3/3.12.0-3/gwt-commons-lang3-3.12.0-3.jar!/org/apache/commons/lang3/ObjectUtils.java'
               [ERROR] Line 1343: Method references are allowed only at source level 1.8 or above
         [ERROR] Hint: Your source appears not to live underneath a subpackage called 'client'; no problem, but you'll need to use the <source> directive in your module to make it accessible
         Tracing compile failure path for type 'org.apache.commons.lang3.ArrayUtils'
            [ERROR] Errors in 'jar:file:/C:/Users/11033178/.m2/repository/de/knightsoft-net/gwt-commons-lang3/3.12.0-3/gwt-commons-lang3-3.12.0-3.jar!/org/apache/commons/lang3/ArrayUtils.java'
               [ERROR] Line 3794: Method references are allowed only at source level 1.8 or above
         [ERROR] Hint: Your source appears not to live underneath a subpackage called 'client'; no problem, but you'll need to use the <source> directive in your module to make it accessible
         Tracing compile failure path for type 'org.apache.commons.lang3.StringUtils'
            [ERROR] Errors in 'jar:file:/C:/Users/11033178/.m2/repository/de/knightsoft-net/gwt-commons-lang3/3.12.0-3/gwt-commons-lang3-3.12.0-3.jar!/org/apache/commons/lang3/StringUtils.java'
               [ERROR] Line 1214: Method references are allowed only at source level 1.8 or above
               [ERROR] Line 2001: The method getBytes(String) in the type String is not applicable for the arguments (Charset)
               [ERROR] Line 1152: Method references are allowed only at source level 1.8 or above
         [ERROR] Hint: Your source appears not to live underneath a subpackage called 'client'; no problem, but you'll need to use the <source> directive in your module to make it accessible
         Tracing compile failure path for type 'org.apache.commons.lang3.Validate'
            [ERROR] Errors in 'jar:file:/C:/Users/11033178/.m2/repository/de/knightsoft-net/gwt-commons-lang3/3.12.0-3/gwt-commons-lang3-3.12.0-3.jar!/org/apache/commons/lang3/Validate.java'
               [ERROR] Line 390: The method requireNonNull(T, String) in the type Objects is not applicable for the arguments (T, () -> {})
               [ERROR] Line 343: Lambda expressions are allowed only at source level 1.8 or above
               [ERROR] Line 249: The method requireNonNull(T, String) in the type Objects is not applicable for the arguments (T[], () -> {})
               [ERROR] Line 249: Lambda expressions are allowed only at source level 1.8 or above
               [ERROR] Line 296: The method requireNonNull(T, String) in the type Objects is not applicable for the arguments (T, () -> {})
               [ERROR]**strong text** Line 441: Lambda expressions are allowed only at source level 1.8 or above
               [ERROR] Line 226: Lambda expressions are allowed only at source level 1.8 or above
               [ERROR] Line 390: Lambda expressions are allowed only at source level 1.8 or above
               [ERROR] Line 226: The method requireNonNull(T, String) in the type Objects is not applicable for the arguments (T, () -> {})
               [ERROR] Line 296: Lambda expressions are allowed only at source level 1.8 or above
               [ERROR] Line 343: The method requireNonNull(T, String) in the type Objects is not applicable for the arguments (T, () -> {})
               [ERROR] Line 441: The method requireNonNull(T, String) in the type Objects is not applicable for the arguments (T, () -> {})
         [ERROR] Hint: Your source appears not to live underneath a subpackage called 'client'; no problem, but you'll need to use the <source> directive in your module to make it accessible
         Unification traversed 50904 fields and methods and 4978 types. 4934 are considered part of the current module and 4934 had all of their fields and methods traversed.
      [ERROR] Compiler returned false
      [WARN] recompile failed
      [WARN] continuing to serve previous version

标签: eclipsetomcatgwt

解决方案


您正在使用 GWT 2.7,它不支持 Java 8 语法(您至少需要 GWT 2.8,最新的是 2.9.0),但是您正在使用诸如 gwt-commons-lang3 版本 3.12.0-3 之类的库Java 8 语法(可能还有库)。

降级您正在使用的库,或者升级到可以处理 Java 8 语法(和库)的更新版本的 GWT。


推荐阅读