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

已配置JDK 1.8执行Maven构建仍报错:需JDK或tools.jar

问题:Maven构建报错提示需使用JDK运行或添加tools.jar到类路径

执行Maven构建时出现以下错误:

org.apache.maven.plugin.MojoExecutionException: You need to run the build with JDK or have tools.jar on the classpath.If this occurs during eclipse build, make sure you run Eclipse under JDK as well

已做配置及操作

  • 项目基于Java 1.8、Maven 3.3.9构建,开发环境为Eclipse
  • 已关联包含tools.jar的JDK 1.8,配置了Java和Maven环境变量
  • Eclipse中Preference > Java > Installed JREs已设置为JDK 1.8
  • 勾选了Eclipse的Maven > Java Configurator对应选项
  • 尝试过手动添加tools.jar到项目引用库

报错相关的pom.xml构建配置

<build>
    <plugins>
        <plugin>
            <groupId>com.mysema.maven</groupId>
            <artifactId>apt-maven-plugin</artifactId>
            <version>1.1.3</version>
            <executions>
                <execution>
                    <goals>
                        <goal>process</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>target/generated-sources/java</outputDirectory>
                        <processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
                    </configuration>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>com.querydsl</groupId>
                    <artifactId>querydsl-apt</artifactId>
                    <version>${querydsl.version}</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>

请问还需要检查哪些配置项,或者提供哪些额外信息来定位问题?

内容的提问来源于stack exchange,提问作者Alejandro Manuel Carrion

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.13 20:03:13