【问题标题】:Gradle giving ClassNotFoundException while building Grails projectGradle 在构建 Grails 项目时给出 ClassNotFoundException
【发布时间】:2015-07-04 01:33:28
【问题描述】:

我正在尝试使用 gradle-grails-plugin 来构建现有的(小型)Grails 项目。这应该工作吗? build.gradle中的依赖和buildConfig.groovy中指定的依赖是什么关系?

无论如何,我有两个项目,所以最上面的build.gradle 文件在父目录中,看起来像:

buildscript {
   repositories {
      jcenter()
   }
   dependencies {
      classpath "org.grails:grails-gradle-plugin:2.2.0.RC1"
   }
}

task wrapper(type: Wrapper) {
   gradleVersion = '2.3'
}

然后Grails项目中的build.gradle如下:

apply plugin: "grails"

repositories {
   grails.central() //creates a maven repo for the Grails Central repository (Core libraries and plugins)
}

grails {
   grailsVersion = '2.4.4'
   groovyVersion = '2.3.9'
   springLoadedVersion '1.2.0.RELEASE'
}

dependencies {
   bootstrap "org.grails.plugins:tomcat:7.0.55.3" 
   compile 'org.grails.plugins:asset-pipeline:3.0.1' 

   compile 'org.grails.plugins:scaffolding:2.1.2'
   compile 'org.grails.plugins:cache:1.1.8'

   runtime 'org.grails.plugins:hibernate4:4.3.1.1'
   runtime 'org.grails.plugins:database-migration:1.3.8'
   runtime 'org.grails.plugins:jquery:1.11.0'
}

但是,当我运行 ./gradlew war 时,我会返回:

Caused by: java.long.ClassNotFoundException: grails.artefact.Service

任何人都可以对此有所了解吗?几乎没有通过谷歌引用它,它似乎是一个 Grails 3.x 类?另外,我使用的是 Java 1.7。

【问题讨论】:

    标签: grails gradle grails-plugin build.gradle


    【解决方案1】:

    grails.artefact.Service 确实可以从 grails 框架 v3.0 访问 - 正如 here 所见。

    使用下面的语句grailsVersion = '2.4.4' v2.4.4 被指定使用,看起来一切正常。破坏构建的是以下dependencies 条目:

    compile 'org.grails.plugins:asset-pipeline:3.0.1' 
    

    在这个包中有一个类asset/pipeline/grails/AssetProcessorService,它导入了在运行时没有加载的grails.artefact.Service(可能是因为使用了v2.4.4)。

    不幸的是,除了排除这种依赖关系之外,我无法提出任何解决方案。我不是 grails 开发人员,也没有设置环境。

    希望能有所帮助。

    【讨论】:

    • @JoeG,有帮助吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-05-19
    • 1970-01-01
    • 2016-01-30
    • 2020-10-16
    • 2021-12-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多