4

Grails を から2.1.0にアップグレードしてい2.3.7ます。Maven ベースのプロジェクトがあります。2.1.0コマンドはmvn clean installエラーなしで実行されます。それ2.3.7は与える:

Compilation error: startup failed:
/home/freyja/fbc/fbc/search-web-app/grails-app/services/pl/psnc/dlteam/fbc2/services/CacheService.groovy: 4: unable to resolve class grails.plugin.cache.Cacheable
@ line 4, column 1.
import grails.plugin.cache.Cacheable
^

/home/freyja/fbc/fbc/search-web-app/grails-app/services/pl/psnc/dlteam/fbc2/services/CacheService.groovy: 3: unable to resolve class grails.plugin.cache.CachePut
@ line 3, column 1.
import grails.plugin.cache.CachePut
^

cacheGrailsプラグインの最新バージョンを試してみ1.1.1まし2.1.0cache 1.0.0。エラーは同じです。

このファイルがどのようにCacheService.groovy見えるかを確認したところ、実際にこれら 2 つのインポートがあり、それらが必要なようです。cacheplugin zip が.m2フォルダーにダウンロードされていることを確認しました。

cache次のようにプラグインを含めますpom.xml

<dependency>
    <groupId>org.grails.plugins</groupId>
    <artifactId>cache</artifactId>
    <version>1.1.1</version>
    <scope>compile</scope>
    <type>zip</type>
</dependency>

実行grails compileしてもエラーは発生せず、アプリケーションを で実行することもできますgrails run-app。しかし、以前は機能していたように、Maven で機能するようになるとよいでしょう。これで私を助けてもらえますか?

何が起こっているのかを理解できるようになるかもしれない追加の質問が1つあります.Mavenを使用する場合、依存関係はBuildConfig.groovy依然として重要ですか? それらを削除する必要がありますか?これは、プロジェクトで維持する依存関係が 2 セットあり、適切なもののように見えないためです。

編集:

BuildConfig.groovy次のようになります。

grails.servlet.version = "2.5" // Change depending on target container compliance (2.5 or 3.0)
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.target.level = 1.6
grails.project.source.level = 1.6
grails.project.dependency.resolver = "maven" 
//grails.project.war.file = "target/${appName}-${appVersion}.war"

grails.project.dependency.resolution = {
    pom true
    // inherit Grails' default dependencies
    inherits("global") {
        // specify dependency exclusions here; for example, uncomment this to disable ehcache:
        // excludes 'ehcache'
    }
    log "error" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
    checksums true // Whether to verify checksums on resolve

    def gebVersion = "0.7.2"

    repositories {
        inherits true // Whether to inherit repository definitions from plugins

        grailsPlugins()
        grailsHome()
        grailsCentral()

        mavenLocal()
        mavenCentral()

        // uncomment these (or add new ones) to enable remote dependency resolution from public Maven repositories
        //mavenRepo "http://snapshots.repository.codehaus.org"
        //mavenRepo "http://repository.codehaus.org"
        //mavenRepo "http://download.java.net/maven/2/"
        //mavenRepo "http://repository.jboss.com/maven2/"
    }
    dependencies {
        // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.

        // runtime 'mysql:mysql-connector-java:5.1.20'
        compile 'org.tuckey:urlrewritefilter:4.0.3'
        compile 'commons-httpclient:commons-httpclient:3.1'
        compile 'org.apache.httpcomponents:httpclient:4.2.5'
        compile 'org.apache.solr:solr-solrj:4.3.0'
        test 'co.freeside:betamax:1.1.2'
        test "org.codehaus.geb:geb-spock:$gebVersion"

    }

    plugins {
        runtime ":hibernate:3.6.10.12"
        runtime ":jquery:1.11.0.1"
        runtime ":resources:1.1.6"
        test ":spock:0.7"
        test ":geb:$gebVersion"

        // Uncomment these (or add new ones) to enable additional resources capabilities
        //runtime ":zipped-resources:1.0"
        //runtime ":cached-resources:1.0"
        //runtime ":yui-minify-resources:0.1.4"

        build ":tomcat:7.0.52.1"

        runtime ":database-migration:1.3.8"

        compile ':cache:1.1.1'
    }
}

grails.war.resources = {stagingDir ->
    delete(dir: "${stagingDir}/WEB-INF/classes/pl/psnc/dlteam/fbc2/utils/iso693_2")
}

しかし、それはMavenビルドにまったく使用されていますか? もしそうなら、なぜプラグインを含める必要があるのpom.xmlですか?. この冗長性は私を悩ませます。

4

1 に答える 1

0

BuildConfig.groovy

この行を入れてください

dependencies {
        compile "net.sf.ehcache:ehcache-core:2.4.6"

    }
于 2014-04-21T06:44:04.467 に答える