私のプロジェクトはSpring+JPA + Hibernateに基づいており、以前はAntを使用してビルドプロセスを管理していましたが、現在はGradleを使用する予定です。'gradle clean test'を実行すると、次のような例外が発生しました。
[2013-02-07 11:01:36,703][テストワーカー][警告][QuerySplitter]クエリクラスの永続クラスが見つかりません:from com.mpos.lottery.te.workingkey.domain.WorkingKey w where w.createDateStr = :createDateStrおよびw.gpeId =:gpeId
[2013-02-07 11:01:36,718][テストワーカー][エラー][TEPortServlet] org.hibernate.QueryParameterException:名前付きパラメーター[gpeId]が見つかりませんでした。ネストされた例外はjava.lang.IllegalArgumentExceptionです:org.hibernate.QueryParameterException:名前付きパラメーター[gpeId]が見つかりませんでした
私はそのテストケース(桟橋は必要ありません)をEclipseとAntの両方で実行しましたが、合格したので、gradleの設定が正しくないとこの例外が発生する可能性があります。
以下は私のgradleスクリプトです:
apply plugin: 'war'
// 'war' plugin will apply 'java' plugin automatically
apply plugin: 'java'
apply plugin: 'eclipse'
// run web application, refer to http://gradle.org/docs/current/userguide/jetty_plugin.html
apply plugin: 'jetty'
compileJava.options.encoding = _sourcecode_encoding
compileTestJava.options.encoding = _sourcecode_encoding
// Properties added by the java plugin
sourceCompatibility="${_source_compatibility}"
targetCompatibility="${_target_compatibility}"
//Properties added by the 'war' plugin
webAppDirName="src/main/WWW"
configurations {
provided {
description = 'Non-exported comiple-time dependencies, it will be provided by container.'
}
}
dependencies {
provided files('lib/DEV/j2ee/servlet-api.jar')
compile fileTree(dir: 'lib', include: '**/*.jar', exclude: 'DEV/**/*.jar')
//compile sourceSets.main.output
testCompile fileTree(dir:"lib", include:"DEV/**/*.jar")
}
sourceSets {
main {
compileClasspath = compileClasspath + configurations.provided
//compileClasspath.collect().each({println it})
resources {
srcDir 'src/main/resource'
}
}
test {
resources {
srcDir 'src/test/resource'
}
}
}
test {
scanForTestClasses = false
classpath = configurations.provided + configurations.compile + configurations.testCompile + sourceSets.main.output + sourceSets.test.output
classpath.each({println it})
// customize test process
include 'com/mpos/lottery/te/gameimpl/smsraffle/**/*Test.class'
}
私はGradleとGroovyの新しい学習者です、plsは私を助けてくれます。前もって感謝します。