maven - Grails 更新后无法解析类 grails.plugin.cache.Cacheable

标签 maven grails grails-cache

我正在从 2.1.0 升级 Grails至 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
^

我尝试了最新版本的 Grails cache插件 - 1.1.1和与 Grails 一起工作的那一个 2.1.0 , 即 cache 1.0.0 .错误是一样的。

我检查了这个文件 CacheService.groovy看起来,它确实有这两个进口,似乎需要它们。我查了一下 cache插件 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 中工作会很好,因为它以前工作过。你能帮我解决这个问题吗?

我还有一个问题,也许可以让我了解正在发生的事情:如果我使用 Maven,则 BuildConfig.groovy 中的依赖项|还重要吗?我应该删除它们吗?因为现在我们在项目中要维护两组依赖项,这看起来不太合适。

编辑:
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 中包含插件? ?.这种冗余困扰着我。

最佳答案

构建配置文件

把这条线

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

    }

关于maven - Grails 更新后无法解析类 grails.plugin.cache.Cacheable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23132923/

相关文章:

grails - 在 gwt 中使用 config.groovy 来获取用户偏好

caching - Grails-全页缓存

maven - Sonarqube 运行后不显示代码覆盖率

java - Maven 创建具有相同依赖项的多模块

python - 使用 xPath 从 pom 中提取版本号时遇到问题

grails - 在常规Groovy类上使用Grails缓存插件注释

java - 从 POM 调用外部 jar 文件

grails - 如何在Grails 2.4.X上启用HAL分页链接

java - Thread.currentThread().contextClassLoader.getResource(path) 似乎缓存结果。可以预防吗?