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

安装Eclipse WindowsBuilder插件后Maven构建出现java.lang.NoClassDefFoundError

Eclipse安装WindowsBuilder后Maven构建报错解决指南

环境信息

  • Eclipse版本:2022-03 (4.23.0),Build id: 20220310-1457
  • 使用Maven构建,非Maven构建正常,安装WindowsBuilder插件前Maven构建无异常

报错信息

安装WindowsBuilder后,Maven构建抛出以下错误:

constituent[40]: file:/C:/eclipse/configuration/org.eclipse.osgi/1285/0/.cp/
constituent[41]: file:/C:/eclipse/configuration/org.eclipse.osgi/443/0/.cp/
constituent[42]: file:/C:/eclipse/configuration/org.eclipse.osgi/20/0/.cp/

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/util/concurrent/internal/InternalFutureFailureAccess
at java.base/java.lang.ClassLoader.defineClass1(Native Method)

异常排查发现

对比安装插件前的配置,configuration/org.eclipse.osgi目录下新增了多个文件夹,上述三个文件夹为新增内容,疑似问题根源,但删除这些文件夹后Eclipse无法启动。

项目pom.xml配置参考

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>Schulefant</groupId>
    <artifactId>MavenMitarbeiterGUIAndCI</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><!-- Auf diese properties wird unten mit ${} zugegriffen -->
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <junit.jupiter.version>5.8.1</junit.jupiter.version> 
        <junit.platform.version>1.8.1</junit.platform.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>${junit.jupiter.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>${junit.jupiter.version}</version>
            <scope>test</scope><!-- wird nur bei mvn test durchgeführt, aber nicht bei mvn compile -->
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-params</artifactId>
            <version>${junit.jupiter.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-suite</artifactId>
            <version>${junit.platform.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.2</version>
                <configuration>
                    <argLine>
                        --illegal-access=permit
                    </argLine>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.22.2</version>
                <configuration>
                    <argLine>
                        --illegal-access=permit
                    </argLine>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <archive>
                        <!-- Configures the content of the created manifest -->
                        <manifest>
                            <!-- Adds the classpath to the created manifest -->
                            <addClasspath>true</addClasspath>
                            <!-- Specifies that all dependencies of our application are found -->
                            <!-- Configures the main class of the application -->
                            <mainClass>RunMitarbeiterverwaltung</mainClass>
                        </manifest>
                    </archive>
                </configuration>

            </plugin>
        </plugins>
    </build>
</project>

解决方法

1. 修复Guava依赖冲突

报错中的InternalFutureFailureAccess属于Guava库类,WindowsBuilder大概率引入了与项目不兼容的Guava版本,导致依赖冲突:

  • 打开Eclipse的Maven依赖视图,搜索guava,查看是否存在多版本依赖。
  • 在pom.xml中显式声明适配JDK8的Guava版本(如28.2-jre),强制统一依赖:
<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava</artifactId>
    <version>28.2-jre</version>
</dependency>

2. 清理缓存与更新依赖

  • 执行Project > Clean清理项目构建缓存。
  • 右键项目选择Maven > Update Project,勾选Force Update of Snapshots/Releases后更新。
  • 删除本地Maven仓库中com/google/guava路径下的所有文件,重新执行mvn clean install。

3. 调整Eclipse构建隔离设置

  • 打开Run Configurations,找到对应的Maven构建配置,切换到Environment标签检查是否有异常类路径变量。
  • 勾选Run in separate JRE,选择与项目编译版本匹配的JDK8。

4. 重新安装适配版本的WindowsBuilder

若以上方法无效,可能是插件版本与Eclipse不兼容:

  • 卸载当前WindowsBuilder插件,从Eclipse Marketplace安装适配2022-03版本的稳定版插件。
  • 或下载对应版本的离线插件包手动安装。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.16 07:30:52