基本 Spring Boot 本机应用程序使用 Maven 构建,但不使用 gradle

问题描述 投票:0回答:1

我有一个基本的 Spring Boot 应用程序。使用maven配置一切都很好。我可以构建一个本机镜像,也可以构建一个容器镜像:

./mvnw -Pnative native:compile -DskipTest
./mvnw -Pnative spring-boot:build-image

与gradle相同的来源给出错误。我几乎确定 build.gradle 没问题:

plugins {
    id 'java'
    id 'org.springframework.boot' version '3.2.5'
    id 'io.spring.dependency-management' version '1.1.4'
    id 'org.graalvm.buildtools.native' version '0.9.28'
}

group = 'dev.sezerb.nativeapp'
version = '0.0.1-SNAPSHOT'

java {
    sourceCompatibility = '17'
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-validation'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

tasks.named('test') {
    useJUnitPlatform()
}

但是当我运行“gradle bootBuildImage”时:我得到以下响应:

 gradle bootBuildImage
> Task :collectReachabilityMetadata FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':collectReachabilityMetadata'.
> Failed to query the value of task ':collectReachabilityMetadata' property 'metadataService'.
   > Failed to create service 'nativeConfigurationService'.
      > Could not create an instance of type org.graalvm.buildtools.gradle.internal.GraalVMReachabilityMetadataService.
         > com.fasterxml.jackson.databind.exc.MismatchedInputException: No content to map due to end-of-input
            at [Source: (BufferedReader); line: 1, column: 0]

对此有何评论?

spring-boot gradle native graalvm
1个回答
0
投票

将 org.graalvm.buildtools.native 从 '0.9.28' 更改为 '0.10.1' 后,构建问题消失了。原生图像似乎工作正常。

© www.soinside.com 2019 - 2024. All rights reserved.