我想在SpringBoot2.3.10.RELEASE项目中使用GraalVM,因为它可以减少JVM的内存使用量(现在我使用JDK 11),因此我添加了依赖项:
api "org.springframework.experimental:spring-native:0.10.2"添加gradle插件:
apply plugin: "com.github.ayltai.spring-graalvm-native-plugin"添加本机构建配置:
nativeImage {
mainClassName = 'com.dolphin.soa.manage.AppStarter'
traceClassInitialization = true
reportExceptionStackTraces = true
removeUnusedAutoConfig = true
removeYamlSupport = true
removeSpelSupport = true
removeJmxSupport = true
maxHeapSize = '4G'
}最后,我使用这个Gradle(7.0)命令来构建一个本机jar:
./gradlew clean :dolphin-manage:dolphin-manage-service:bootBuildImage -x test但请显示此错误:
> Configure project :dolphin-acientbay
/Users/dolphin/source/retire
> Configure project :dolphin-post
/Users/dolphin/source/retire
> Configure project :dolphin-template
/Users/dolphin/source/retire
> Task :dolphin-common:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':dolphin-common:compileJava'.
> java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor (in unnamed module @0x2155f75f) cannot access class com.sun.tools.javac.processing.JavacProcessingEnvironment (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.processing to unnamed module @0x2155f75f
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 6m 49s
5 actionable tasks: 1 executed, 4 up-to-date
(base)这是GraalVM和lombok的兼容问题吗?有可能修好吗?
发布于 2022-06-22 00:23:12
我看到同样类型的错误在我的Java项目上一尘不染地运行。我刚向他们报告了一个bug:https://github.com/diffplug/spotless/issues/1244
我把这个问题诊断为Java 15和Java 16之间的某种行为变化。所以,您可以做的一件事是恢复到早期版本的Java,看看这是否使问题消失。如果是这样的话,您应该报告一个类似于我在这个问题上对项目所做的错误,这样他们就可以尝试修复它。
https://stackoverflow.com/questions/68755132
复制相似问题