【问题标题】:error while running grails command line运行 grails 命令行时出错
【发布时间】:2014-02-17 13:38:15
【问题描述】:

在我的 grails 2.3.4 应用程序中(从 grails 2.2.3 升级后),当我运行 grails 命令行 grails install-plugin pluginname 时,我收到以下错误,即使我尝试了 grails list-plugins 我也遇到了同样的错误:

    Error Resolve error obtaining dependencies: Failed to resolve dependencies (Se log level to 'warn' in BuildConfig.groovy for more information): org.grails.plugins:tomcat:2.3.4 (Use --stacktrace to see the full trace)

我查看了 BuildConfig.groovy,没有 tomcat 2.3.4 我使用的是 7.0.47,这是我的插件:

runtime ":hibernate:3.6.10.6"
runtime ":jquery:1.8.3"
runtime  :resources:1.1.6
build ":tomcat:7.0.47"
runtime database-migration:1.2.1
compile :cache:1.0.1

我该如何解决这个问题?

【问题讨论】:

  • 您能否将日志级别设置为“警告”并按照错误提示使用 --stacktrack ?这将更加冗长,并明确指出哪些依赖关系没有得到解决。此外,如果您在 BuildConfig 中设置依赖项,则无需在命令行上运行 install-plugin。
  • .grails 中清理您的项目。发出grails clean 并继续前进。另请注意,grails install-plugin 在 Grails 2.3.* 中不再使用。插件必须手动安装在BuildConfig。作为旁注,还要检查 application.properties 不是指任何插件。
  • 请确保您在 BuildConfig 中的插件用引号括起来并以冒号开头。例如,你有runtime database-migration:1.2.1,而它应该是runtime ":database-migration:1.2.1"
  • @dmahapatro 即使使用 grails clean ,我也会遇到上述错误
  • @grantmc 如果我写单引号或双引号会有什么不同吗?

标签: grails


【解决方案1】:

您的问题似乎很无聊,因为...您需要先清理 grails 项目而不构建它,然后再执行

grails refresh-dependencies

最后是

grails clean

grails compile

当您运行refresh-dependencies 时,您的Grails 应用程序将尝试解析您在BuildConfig.groovy 文件中定义的grails 插件。如果这不起作用,请删除插件并执行上述步骤,直到您在问题中发布的错误消失,然后添加正确的插件格式和具有正确优先级依赖关系的版本,然后确保一切正常。

【讨论】:

    【解决方案2】:

    您的依赖项位于依赖项块中,但它们是插件。将它们放在您的 BuildConfig.groovy 文件的插件块中。因此,不要使用您所拥有的,而是这样写:

    plugins {    
        runtime ":hibernate:3.6.10.6"
        runtime ":jquery:1.8.3"
        runtime ":resources:1.1.6"
        build   ":tomcat:7.0.47"
        runtime ":database-migration:1.2.1"
        compile ":cache:1.0.1"
    }
    

    此外,这不是“依赖”块。然而,这是一个依赖块。请参阅this link 了解有关 Grails 中依赖项解析的信息。

    【讨论】:

      【解决方案3】:

      我需要将 buildconfig.groovy 中的以下 repo 添加到 repositories 部分:

      mavenRepo "https://repo.grails.org/grails/plugins"
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-04-07
        • 2014-08-01
        • 2016-11-11
        • 2020-04-22
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多