首页 > 解决方案 > 设置 Spring Native Experimental(在以下任何来源中均未找到 id 'org.springframework.experimental.aot' 版本 '0.10.3')

问题描述

你好女士们先生们,

所以我只是想通过使用 Spring Native 为我的 Spring 应用程序获取可执行文件。

我的 build.gradle:

plugins {
    id 'org.springframework.boot' version '2.5.4'
    id 'io.spring.dependency-management' version '1.0.10.RELEASE'
    id 'java'
    id 'org.springframework.experimental.aot' version '0.10.3'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa:2.5.4'
    implementation 'org.springframework.boot:spring-boot-starter-web:2.5.4'
    compileOnly 'org.projectlombok:lombok:1.18.20'
    annotationProcessor 'org.projectlombok:lombok:1.18.20'
    testImplementation 'org.springframework.boot:spring-boot-starter-test:2.5.4'
    implementation group: 'org.postgresql', name: 'postgresql', version: '42.2.14'
    implementation group: 'org.apache.poi', name: 'poi', version: '4.1.2'
    implementation group: 'org.apache.poi', name: 'poi-ooxml', version: '4.1.2'
    implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.14.6'
    implementation group: 'org.json', name: 'json', version: '20180813'
}

test {
    useJUnitPlatform()
}

和我的 settings.gradle: rootProject.name = 'demo'

在将“org.springframework.experimental.aot”版本“0.10.3”插件添加到 build.gradle 后,如上所示(按照 2.1.2 https://docs.spring.io/spring- native/docs/current/reference/htmlsingle/#getting-started),我收到以下错误:

org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'org.springframework.experimental.aot', version: '0.10.3'] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'org.springframework.experimental.aot:org.springframework.experimental.aot.gradle.plugin:0.10.3')
  Searched in the following repositories:
    Gradle Central Plugin Repository

标签: javaspringspring-bootgradlespring-native

解决方案


评论的人是对的,尽管我认为由于教程乱七八糟,我认为这是不必要的粗鲁,并且他们告诉您在向您提供安装说明之前应用该插件。

更具体地说,您需要将 spring release maven repo 添加到您settings.gradle.kts的插件中以获取插件

pluginManagement {
  repositories {
    gradlePluginPortal()
    maven { url = uri("https://repo.spring.io/release") }
    mavenLocal()
  }
}

然后还将存储库添加到您build.gradle.kts的以获取依赖项

repositories {
  maven { url = uri("https://repo.spring.io/release") }
}

推荐阅读