You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

升级GWT至2.10.0及Maven编译版本至1.8.0后遇异常求助

GWT 2.10.0 + Java 8 升级错误解决方案

1. 测试阶段 NoClassDefFoundError: org/w3c/dom/ElementTraversal 解决

  • 问题原因:该类属于W3C DOM规范,Java 8环境下可能因依赖缺失或类路径冲突导致无法加载。
  • 解决方案:
    在pom.xml中添加xml-apis依赖,限定测试范围避免影响主代码:
    <dependency>
        <groupId>xml-apis</groupId>
        <artifactId>xml-apis</artifactId>
        <version>1.4.01</version>
        <scope>test</scope>
    </dependency>
    
    若问题仍存在,执行mvn dependency:tree检查是否存在冲突的XML相关依赖,排除重复或版本不一致的依赖项。

2. Tomcat编译阶段 NoSuchMethodError: MessageSend.binding() 解决

  • 问题原因:GWT 2.10.0依赖特定版本的Eclipse JDT编译器,项目中其他依赖引入的JDT版本与GWT要求的版本冲突,导致方法找不到。
  • 解决方案:
    1. 统一Eclipse JDT版本:在pom.xml中引入与GWT 2.10.0适配的JDT核心依赖:
      <dependency>
          <groupId>org.eclipse.jdt</groupId>
          <artifactId>org.eclipse.jdt.core</artifactId>
          <version>3.24.0</version>
          <scope>provided</scope>
      </dependency>
      
    2. 排除冲突依赖:执行mvn dependency:tree查找所有org.eclipse.jdt.core依赖,在冲突的依赖项中添加排除规则:
      <exclusion>
          <groupId>org.eclipse.jdt</groupId>
          <artifactId>org.eclipse.jdt.core</artifactId>
      </exclusion>
      
    3. 确认Maven编译插件配置:确保maven-compiler-plugin版本支持Java 8,且source/target设置正确:
      <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.8.1</version>
          <configuration>
              <source>1.8</source>
              <target>1.8</target>
          </configuration>
      </plugin>
      
    4. 配置GWT Maven插件:确保gwt-maven-plugin版本为2.10.0,并指定sourceLevel为1.8:
      <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>gwt-maven-plugin</artifactId>
          <version>2.10.0</version>
          <configuration>
              <sourceLevel>1.8</sourceLevel>
              <!-- 保留其他原有配置 -->
          </configuration>
      </plugin>
      

内容的提问来源于stack exchange,提问作者codemonkey

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.07 08:37:17