scala - 为什么 Play 2.3.4 和 jacoco4sbt > 2.1.4 会失败并出现 NoSuchMethodError?

标签 scala sbt jacoco playframework-2.3

我正在尝试在我的 Play 2.3.4 (scala 2.10.4) 应用程序中使用 jacoco4sbt,但似乎只有 2.1.4 可以工作。当我使用 .5 或 .6 时,出现以下错误:

[error] (main/jacoco:fullClasspath) java.lang.NoSuchMethodError:
org.objectweb.asm.MethodVisitor.visitMethodInsn(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)V

我尝试将 asm-all (版本 4.1 和 5.0.3)添加到依赖项中,但这根本没有帮助。

那么可能是什么问题呢?我需要添加任何额外的依赖项吗?

最佳答案

They have indeed changed the ASM version到 5.0.1,即使这样我也无法重现您的问题。

项目/build.properties

sbt.version=0.13.7-M3

project/plugins.sbt

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.4")

plugins/jacoco4sbt.sbt

addSbtPlugin("de.johoop" % "jacoco4sbt" % "2.1.6")

build.sbt

name := """play-jacoco"""

version := "1.0-SNAPSHOT"

enablePlugins(PlayScala)

scalaVersion := "2.11.2"

libraryDependencies ++= Seq(
  jdbc,
  anorm,
  cache,
  ws
)

pipelineStages := Seq(rjs, digest, gzip)

jacoco.settings

当我运行 jacoco:cover 时,它工作得很好。

[play-uglify] $ jacoco:cover
[info] Compiling 2 Scala sources to /Users/jacek/sandbox/play-uglify/target/scala-2.11/test-classes...
SLF4J: The following set of substitute loggers may have been accessed
SLF4J: during the initialization phase. Logging calls during this
SLF4J: phase were not honored. However, subsequent logging calls to these
SLF4J: loggers will work as normally expected.
SLF4J: See also http://www.slf4j.org/codes.html#substituteLogger
SLF4J: org.apache.http.impl.client.DefaultHttpClient
SLF4J: com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl
SLF4J: com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter
SLF4J: com.gargoylesoftware.htmlunit.DefaultCssErrorHandler
SLF4J: com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration
SLF4J: com.gargoylesoftware.htmlunit.WebClient
SLF4J: com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine
SLF4J: com.gargoylesoftware.htmlunit.WebResponse
[info] IntegrationSpec
[info]
[info] Application should
[info] + work from within a browser
[info]
[info] Total for specification IntegrationSpec
[info] Finished in 29 ms
[info] 1 example, 0 failure, 0 error
[info] ApplicationSpec
[info]
[info] Application should
[info] + send 404 on a bad request
[info] + render the index page
[info]
[info] Total for specification ApplicationSpec
[info] Finished in 29 ms
[info] 2 examples, 0 failure, 0 error
[info] Passed: Total 3, Failed 0, Errors 0, Passed 3
[info]
[info] ------- Jacoco Coverage Report --------
[info]
[info] Lines: 57.5% (>= required 0.0%) covered, 34 of 80 missed, OK
[info] Instructions: 72.12% (>= required 0.0%) covered, 522 of 1872 missed, OK
[info] Branches: 27.78% (>= required 0.0%) covered, 26 of 36 missed, OK
[info] Methods: 81.94% (>= required 0.0%) covered, 41 of 227 missed, OK
[info] Complexity: 76.73% (>= required 0.0%) covered, 57 of 245 missed, OK
[info] Class: 57.14% (>= required 0.0%) covered, 12 of 28 missed, OK
[info] Check /Users/jacek/sandbox/play-uglify/target/scala-2.11/jacoco for detail report
[info]
[success] Total time: 6 s, completed Oct 9, 2014 7:42:31 AM

我们的不同之处在哪里?

关于scala - 为什么 Play 2.3.4 和 jacoco4sbt > 2.1.4 会失败并出现 NoSuchMethodError?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26260616/

相关文章:

java - jacoco 仅显示同一模块中类的覆盖率

unit-testing - Groovy Gradle Sonar-runner 单元测试和代码覆盖率

scala - 导入 sbt 项目时出错,服务器访问错误, Unresolved 依赖项

scala - SBT 项目中的 "resources"文件夹有什么用?

scala - sbt:在多项目构建中,如何从项目 A 调用项目 B 的任务?

java - IntelliJ IDEA 测试 - 如何显示分支覆盖率

scala - 与简单的 Scala 打包示例混淆

mysql - 如何正确使用Scala Play Anorm和Option[String]插入NULL SQL

arrays - 如何在 scala 中的二维数组上使用 contains 方法

scala - 给定列表中每个第 n 项的列表