Gradle在构建Grails项目时出现ClassNotFoundException错误

6

我正在尝试使用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。

1个回答

1

grails.artefact.Service确实可以从Grails框架v3.0中访问 - 可以在此处中看到。

使用以下语句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,有帮助吗? - Opal

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接