run-war时Grails异常:NoSuchMethodError

时间:2015-02-08 13:54:05

标签: java grails deployment groovy intellij-idea

我在IntelliJ IDEA上运行run-war时收到以下异常。

| Uglifying File 44 of 464 - application.                     
| Error Error executing script RunWar: com.google.common.collect.Maps.immutableEnumMap(Ljava/util/Map;)Lcom/google/common/collect/ImmutableMap; (NOTE: Stack trace has been filtered.
Use --verbose to see entire trace.)
java.lang.NoSuchMethodError: com.google.common.collect.Maps.immutableEnumMap(Ljava/util/Map;)Lcom/google/common/collect/ImmutableMap;
        at com.google.javascript.jscomp.parsing.parser.Keywords.<clinit>(Keywords.java:94)
        at com.google.javascript.jscomp.parsing.parser.Scanner.scanIdentifierOrKeyword(Scanner.java:681)
        at com.google.javascript.jscomp.parsing.parser.Scanner.scanToken(Scanner.java:569)
        at com.google.javascript.jscomp.parsing.parser.Scanner.peekToken(Scanner.java:228)
        at com.google.javascript.jscomp.parsing.parser.Parser.peekToken(Parser.java:2737)
        at com.google.javascript.jscomp.parsing.parser.Parser.peekToken(Parser.java:2730)
        at com.google.javascript.jscomp.parsing.parser.Parser.getTreeStartLocation(Parser.java:2649)
        at com.google.javascript.jscomp.parsing.parser.Parser.parseProgram(Parser.java:147)
        at com.google.javascript.jscomp.parsing.ParserRunner.parse(ParserRunner.java:102)
        at com.google.javascript.jscomp.JsAst.parse(JsAst.java:84)
        at com.google.javascript.jscomp.JsAst.getAstRoot(JsAst.java:50)
        at com.google.javascript.jscomp.CompilerInput.getAstRoot(CompilerInput.java:118)
        at com.google.javascript.jscomp.Compiler.hoistExterns(Compiler.java:1467)
        at com.google.javascript.jscomp.Compiler.parseInputs(Compiler.java:1369)
        at com.google.javascript.jscomp.Compiler.parse(Compiler.java:788)
        at com.google.javascript.jscomp.Compiler.compileInternal(Compiler.java:743)
        at com.google.javascript.jscomp.Compiler.access$000(Compiler.java:93)
        at com.google.javascript.jscomp.Compiler$3.call(Compiler.java:655)
        at com.google.javascript.jscomp.Compiler$3.call(Compiler.java:652)
        at com.google.javascript.jscomp.Compiler$4.call(Compiler.java:699)

如果我使用run-app运行相同的应用程序,则可以正常运行。

这是BuildConfig.groovy:

        build ":tomcat:7.0.55"

        compile ':cache:1.1.8'
        compile ":asset-pipeline:2.1.1"
        compile ":easygrid:1.6.9"
        compile ":twitter-bootstrap:3.3.2.1"
        compile ':spring-security-core:2.0-RC4'
        compile ":jquery-validation-ui:1.4.9"

        compile ":birt-report:4.3.0.3"

        runtime ":hibernate:3.6.10.18"
        runtime ":database-migration:1.4.0"
        runtime ":jquery:1.11.1"

知道它可能是什么吗?或者如何解决?

4 个答案:

答案 0 :(得分:2)

在Guils 2.5.2应用程序中为我添加构建范围的依赖关系修复了这个问题

dependencies {
    // other dependencies go here 
    build 'com.google.guava:guava:18.0'
}

答案 1 :(得分:1)

https://code.google.com/p/guava-libraries/wiki/UseGuavaInYourBuild

确保BuildConfig中设置了两件事:

repositories {
  mavenCentral()
}

dependencies {
  compile group: 'com.google.guava', name: 'guava', version: '12.0'
}

请确保您使用的是所需的正确版本。然后执行Grails Refresh Dependencies。

答案 2 :(得分:1)

我在Grails 2.5.0上遇到了同样的问题,我通过将番石榴版本提升到最新版本来修复它。

在我grails-app/conf/BuildConfig.groovy中,我现在有:

dependencies {
  compile group: 'com.google.guava', name: 'guava', version: '18.0'
}

这解决了这个问题。

答案 3 :(得分:0)

我遇到了同样的错误并使用最新的资产插件修复了它:  (编译“org.grails.plugins:asset-pipeline:2.11.0”)