Gradle在构建Grails项目时给出ClassNotFoundException

Joe*_*oeG 6 grails grails-plugin gradle build.gradle

我正在尝试使用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'
}
Run Code Online (Sandbox Code Playgroud)

然后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'
}
Run Code Online (Sandbox Code Playgroud)

但是,当我跑步时./gradlew war,我会回来:

Caused by: java.long.ClassNotFoundException: grails.artefact.Service
Run Code Online (Sandbox Code Playgroud)

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

Opa*_*pal 1

确实可以从 grails 框架的 v3.0 访问类grails.artefact.Service- 正如可以在此处看到的。

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

compile 'org.grails.plugins:asset-pipeline:3.0.1' 
Run Code Online (Sandbox Code Playgroud)

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

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

希望能有所帮助。