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

使用Gradle构建Micronaut项目失败求助

Gradle构建Micronaut项目时遭遇Java堆内存溢出失败

问题描述

  • 执行./gradlew build构建Micronaut项目失败,核心报错为Java堆内存溢出
  • 最初怀疑是增量注解处理器警告导致:[WARN] Incremental annotation processing requested, but support is disabled because the following processors are not incremental: io.micronaut.annotation.processing.TypeElementVisitorProcessor (DYNAMIC).,但跳过测试构建(执行./gradlew build -x test)可成功完成,且该警告依然存在
  • 尝试通过IDE的Help -> Change Memory settings将内存调整为4096,无任何效果

环境信息

------------------------------------------------------------
Gradle 7.6
------------------------------------------------------------

Build time:   2022-11-25 13:35:10 UTC
Revision:     daece9dbc5b79370cc8e4fd6fe4b2cd400e150a8

Kotlin:       1.7.10
Groovy:       3.0.13
Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM:          11.0.23 (Eclipse Adoptium 11.0.23+9)
OS:           Mac OS X 14.5 aarch64

完整报错日志

> Task :service:kaptKotlin
[WARN] Issue detected with io.micronaut.annotation.processing.TypeElementVisitorProcessor. Expected 1 originating source file when generating /Users/xxxx/Work/foo-service/service/build/generated/source/kapt/main/dummy588074428538458, but detected 0: [].
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: 相关详情可查看SLF4J官方文档

java.lang.OutOfMemoryError: Java heap space
Exception in thread "Daemon client event forwarder" java.lang.OutOfMemoryError: Java heap space
        at java.base/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.addConditionWaiter(AbstractQueuedSynchronizer.java:1896)
        at java.base/java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2114)
        at java.base/java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:458)
        at org.gradle.launcher.daemon.server.exec.DaemonConnectionBackedEventConsumer$ForwardEvents.getNextEvent(DaemonConnectionBackedEventConsumer.java:72)
        at org.gradle.launcher.daemon.server.exec.DaemonConnectionBackedEventConsumer$ForwardEvents.run(DaemonConnectionBackedEventConsumer.java:59)
Error while receiving file changes
net.rubygrapefruit.platform.NativeException: Caught java.lang.OutOfMemoryError with message: Java heap space
        at net.rubygrapefruit.platform.internal.jni.AbstractNativeFileEventFunctions$NativeFileWatcher.executeRunLoop0(Native Method)
        at net.rubygrapefruit.platform.internal.jni.AbstractNativeFileEventFunctions$NativeFileWatcher.executeRunLoop(AbstractNativeFileEventFunctions.java:42)
        at net.rubygrapefruit.platform.internal.jni.AbstractFileEventFunctions$AbstractFileWatcher$1.run(AbstractFileEventFunctions.java:154)
45 actionable tasks: 45 executed

> Task :service:kaptKotlin FAILED
Note: Generating OpenAPI Documentation

FAILURE: Build failed with an exception.

* What went wrong:
Gradle build daemon has been stopped: JVM garbage collector thrashing and after running out of JVM memory

补充信息

  • 设备总内存64GB,已设置环境变量JAVA_TOOL_OPTIONS为-Xms512m -Xmx48g,但问题仍未解决

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.22 08:06:15