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

Grails 6通过create-app/create-restapi创建项目构建失败求助

解决Grails 6项目构建失败的思路

1. 无法解析Spring Boot依赖:补充必要仓库配置

执行gradle dependencies提示找不到org.springframework.boot:spring-boot-dependencies:2.7.18,核心原因是项目Gradle配置中缺少官方仓库源。

  • 检查项目根目录的settings.gradle,确保pluginManagement块包含以下仓库:
    pluginManagement {
        repositories {
            mavenCentral()
            gradlePluginPortal()
            maven { url "https://repo.grails.org/grails/core" }
        }
    }
    
  • 打开build.gradle,确认repositories块中同样配置了这些仓库:
    repositories {
        mavenCentral()
        maven { url "https://repo.grails.org/grails/core" }
    }
    
  • 若使用第三方镜像(如阿里云),需确认镜像已同步Spring Boot和Grails的官方依赖,避免镜像缺失导致拉取失败。

2. views-json插件任务创建失败:匹配兼容版本

org.grails.plugins.views-json:3.1.1与Grails 6版本不兼容,会触发compileGsonViews任务初始化异常。

  • 修改build.gradle中的插件版本为Grails 6兼容的3.2.x系列,例如:
    plugins {
        id "org.grails.plugins.views-json" version "3.2.0"
    }
    
  • 清理Gradle缓存并重新构建:
    ./gradlew clean build --refresh-dependencies
    

3. domain文件夹缺失:新结构的正常调整

Grails 6调整了默认目录结构,不再自动生成grails-app/domain文件夹,domain类默认放在src/main/groovy或src/main/java下的对应包路径中。

  • 若偏好旧结构,可手动创建grails-app/domain目录,Gradle会自动识别该目录作为domain类的源目录,无需额外配置。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.30 11:26:03