使用Spring Initializr初始化项目时报Gradle不兼容错误(Spring Boot 3.5.0)

运行时出现以下错误

Execution failed for task ':com.jiayi.Fluoro.FluoroApplication.main()'.
> Process 'command 'C:\Users\littleGabriel\.jdks\openjdk-23.0.1\bin\java.exe'' finished with non-zero exit value 1

* 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.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.12.1/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD FAILED in 13s
3 actionable tasks: 3 executed

执行./gradlew build --warning-mode all查看具体错误:

Welcome to Gradle 8.12.1!

Here are the highlights of this release:
 - Enhanced error and warning reporting with the Problems API
 - File-system watching support on Alpine Linux
 - Build and test Swift 6 libraries and apps

For more details see https://docs.gradle.org/8.12.1/release-notes.html

Settings file 'D:\Java\Fluoro\settings.gradle': line 3
Space-assignment syntax in Groovy DSL has been deprecated. This is scheduled to be removed in Gradle 10.0. Use assignment ('url = <value>') instead. Consult the upgrading guide for further information: https://docs.gradle.org/8.12.1/userguide/upgrading_version_8.html#groovy_space_assignment_syntax
        at settings_eztmocxweyoal283sy9dmbts5$_run_closure1$_closure2$_closure3.doCall$original(D:\Java\Fluoro\settings.gradle:3)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)
        at settings_eztmocxweyoal283sy9dmbts5$_run_closure1$_closure2.doCall$original(D:\Java\Fluoro\settings.gradle:3)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)
Settings file 'D:\Java\Fluoro\settings.gradle': line 4
Space-assignment syntax in Groovy DSL has been deprecated. This is scheduled to be removed in Gradle 10.0. Use assignment ('url = <value>') instead. Consult the upgrading guide for further information: https://docs.gradle.org/8.12.1/userguide/upgrading_version_8.html#groovy_space_assignment_syntax
        at settings_eztmocxweyoal283sy9dmbts5$_run_closure1$_closure2$_closure4.doCall$original(D:\Java\Fluoro\settings.gradle:4)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)
        at settings_eztmocxweyoal283sy9dmbts5$_run_closure1$_closure2.doCall$original(D:\Java\Fluoro\settings.gradle:4)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)

> Configure project :
Build file 'D:\Java\Fluoro\build.gradle': line 18
Space-assignment syntax in Groovy DSL has been deprecated. This is scheduled to be removed in Gradle 10.0. Use assignment ('url = <value>') instead. Consult the upgrading guide for further information: https://docs.gradle.org/8.12.1/userguide/upgrading_version_8.html#groovy_space_assignment_syntax
        at build_anefe48letf7m205yk518nb2j$_run_closure2$_closure6.doCall$original(D:\Java\Fluoro\build.gradle:18)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)
        at build_anefe48letf7m205yk518nb2j$_run_closure2.doCall$original(D:\Java\Fluoro\build.gradle:18)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)
Build file 'D:\Java\Fluoro\build.gradle': line 19
Space-assignment syntax in Groovy DSL has been deprecated. This is scheduled to be removed in Gradle 10.0. Use assignment ('url = <value>') instead. Consult the upgrading guide for further information: https://docs.gradle.org/8.12.1/userguide/upgrading_version_8.html#groovy_space_assignment_syntax
        at build_anefe48letf7m205yk518nb2j$_run_closure2$_closure7.doCall$original(D:\Java\Fluoro\build.gradle:19)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)
        at build_anefe48letf7m205yk518nb2j$_run_closure2.doCall$original(D:\Java\Fluoro\build.gradle:19)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)

可以看到是格式的问题,修改setting.gradlebuild.gradle:

pluginManagement {
    repositories {
        maven { url 'https://repo.spring.io/milestone' }
        maven { url 'https://repo.spring.io/snapshot' }
        gradlePluginPortal()
    }
}
rootProject.name = 'Fluoro'

改为

pluginManagement {
    repositories {
        maven { url='https://repo.spring.io/milestone' }
        maven { url='https://repo.spring.io/snapshot' }
        gradlePluginPortal()
    }
}
rootProject.name = 'Fluoro'
...
repositories {
    mavenCentral()
    maven { url='https://repo.spring.io/milestone' }
    maven { url='https://repo.spring.io/snapshot' }
}
...

改为

...
repositories {
    mavenCentral()
    maven { url='https://repo.spring.io/milestone' }
    maven { url='https://repo.spring.io/snapshot' }
}
...

完成!

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容