首页 \ 问答 \ scalac:错误:要求失败:包存根(scalac: Error: requirement failed: package stubbing)

scalac:错误:要求失败:包存根(scalac: Error: requirement failed: package stubbing)

我正在使用scala 2.12。 这是我的build.sbt文件

libraryDependencies ++= Seq(
   "net.codingwell" %% "scala-guice" % "4.1.0",
   "org.scalatest" %% "scalatest" % "3.0.3" % "test",
   "org.scalamock" %% "scalamock-scalatest-support" % "3.5.0" % "test"
)

我正在尝试为Guice编写一个测试模块,它也使用Mocking

我试过了

class TestModule extends ScalaModule with MockitoSugar{
   val x = mock[TestPartialMock]
   override def configure(): Unit = {
      bind[Test1]
      bind[Test2]
   }
}

我收到了错误

Error:scalac: Error: requirement failed: package stubbing
java.lang.IllegalArgumentException: requirement failed: package stubbing
    at scala.reflect.internal.Types$ModuleTypeRef.<init>(Types.scala:1879)
    at scala.reflect.internal.Types$PackageTypeRef.<init>(Types.scala:1897)
    at scala.reflect.internal.Types$TypeRef$.apply(Types.scala:2401)
    at scala.reflect.internal.Types.typeRef(Types.scala:3553)
    at scala.reflect.internal.Types.typeRef$(Types.scala:3536)
    at scala.reflect.internal.SymbolTable.typeRef(SymbolTable.scala:16)
    at s

我也试过了

class TestModule extends AbstractModule with ScalaModule with MockitoSugar {
   override def configure() = {
   }
}

但现在我得到了错误

Error:(14, 17) Symbol 'type <none>.stubbing.Answer' is missing from the classpath.
This symbol is required by 'value org.scalatest.mockito.MockitoSugar.defaultAnswer'.
Make sure that type Answer is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
A full rebuild may help if 'MockitoSugar.class' was compiled against an incompatible version of <none>.stubbing.
   override def configure() = {

然后我试了一下

class TestModule extends AbstractModule with ScalaModule with MockFactory with MockitoSugar {
   override def configure() = {
   }
}

但是我得到了这个错误

Error:(14, 17) Symbol 'type <none>.mockito.MockSettings' is missing from the classpath.
This symbol is required by 'value org.scalatest.mockito.MockitoSugar.mockSettings'.
Make sure that type MockSettings is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
A full rebuild may help if 'MockitoSugar.class' was compiled against an incompatible version of <none>.mockito.
   override def configure() = {

在我看来,在同一个类中使用Guice AbstractFactory和MockitoSugar是不可能的。


I am using scala 2.12. This is my build.sbt file

libraryDependencies ++= Seq(
   "net.codingwell" %% "scala-guice" % "4.1.0",
   "org.scalatest" %% "scalatest" % "3.0.3" % "test",
   "org.scalamock" %% "scalamock-scalatest-support" % "3.5.0" % "test"
)

I am trying to write a Test Module for Guice which also uses Mocking

I Tried

class TestModule extends ScalaModule with MockitoSugar{
   val x = mock[TestPartialMock]
   override def configure(): Unit = {
      bind[Test1]
      bind[Test2]
   }
}

I got the error

Error:scalac: Error: requirement failed: package stubbing
java.lang.IllegalArgumentException: requirement failed: package stubbing
    at scala.reflect.internal.Types$ModuleTypeRef.<init>(Types.scala:1879)
    at scala.reflect.internal.Types$PackageTypeRef.<init>(Types.scala:1897)
    at scala.reflect.internal.Types$TypeRef$.apply(Types.scala:2401)
    at scala.reflect.internal.Types.typeRef(Types.scala:3553)
    at scala.reflect.internal.Types.typeRef$(Types.scala:3536)
    at scala.reflect.internal.SymbolTable.typeRef(SymbolTable.scala:16)
    at s

I also tried

class TestModule extends AbstractModule with ScalaModule with MockitoSugar {
   override def configure() = {
   }
}

but now I get error

Error:(14, 17) Symbol 'type <none>.stubbing.Answer' is missing from the classpath.
This symbol is required by 'value org.scalatest.mockito.MockitoSugar.defaultAnswer'.
Make sure that type Answer is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
A full rebuild may help if 'MockitoSugar.class' was compiled against an incompatible version of <none>.stubbing.
   override def configure() = {

Then I tried

class TestModule extends AbstractModule with ScalaModule with MockFactory with MockitoSugar {
   override def configure() = {
   }
}

But I get this error

Error:(14, 17) Symbol 'type <none>.mockito.MockSettings' is missing from the classpath.
This symbol is required by 'value org.scalatest.mockito.MockitoSugar.mockSettings'.
Make sure that type MockSettings is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
A full rebuild may help if 'MockitoSugar.class' was compiled against an incompatible version of <none>.mockito.
   override def configure() = {

It seems to me that its impossible to use the Guice AbstractFactory and the MockitoSugar in the same class.


原文:https://stackoverflow.com/questions/43696394
更新时间:2022-09-20 17:09

最满意答案

如果?:是关联的,那么声明

finalgrade = (grade > 90) ? "high pass" : (grade < 60) ? "fail" : "pass";

将被视为

finalgrade = ((grade > 90) ? "high pass" : (grade < 60)) ? "fail" : "pass";

其中(在这种情况下)不会编译,因为"high pass"(grade < 60)具有不同的类型。

由于它实际上是右关联的,因此该语句被视为

finalgrade = (grade > 90) ? "high pass" : ((grade < 60) ? "fail" : "pass");

If ?: was left associative, the statement

finalgrade = (grade > 90) ? "high pass" : (grade < 60) ? "fail" : "pass";

would be treated as

finalgrade = ((grade > 90) ? "high pass" : (grade < 60)) ? "fail" : "pass";

which (in this case) would not compile, since "high pass" and (grade < 60) have different types.

Since it is actually right associative, the statement is treated as

finalgrade = (grade > 90) ? "high pass" : ((grade < 60) ? "fail" : "pass");

相关问答

更多
  • 这与关联性无关(这在表达式中发挥作用,如a == b == c )。 你问的是操作员操作数的评估顺序。 有一些明确列出的异常,这在C ++中是故意未指定的 。 这意味着不能保证a或b是否会首先在a == b进行评估。 例外(保证评估顺序)是: 函数调用的所有参数在函数调用之前进行评估(但是以未指定的顺序)。 内置运算符||的左侧 并且首先评估&& (如果需要,右侧仅进行评估)。 内置运算符的左侧在右侧之前进行评估。 运算符?:的条件在结果之前被评估,并且只有一个结果被评估。 注意&& , ||的特殊属性 , ...
  • a[i++] = a[i++]; 因为它是未定义的行为。 好阅读: 序列点 未定义的行为和序列点 a[i++] = a[i++]; Because it is Undefined Behavior. Good Read: Sequence Points Undefined Behavior and Sequence Points
  • 如果?:是关联的,那么声明 finalgrade = (grade > 90) ? "high pass" : (grade < 60) ? "fail" : "pass"; 将被视为 finalgrade = ((grade > 90) ? "high pass" : (grade < 60)) ? "fail" : "pass"; 其中(在这种情况下)不会编译,因为"high pass"和(grade < 60)具有不同的类型。 由于它实际上是右关联的,因此该语句被视为 finalgrade = ( ...
  • 你在结合性和秩序或评估之间感到困惑。 参数的评估顺序在C ++中是未指定的。 正如你所提到的那样, operator +关联性从左到右。 要理解这一点,请使用operator -尝试类似的代码片段operator - 从订单或评估 (重点我的) 除了下面指出的地方,在C ++中没有从左到右或从右到左的评估概念。 这不应与运算符的从左到右和从右到左的关联性相混淆 :表达式f1()+ f2()+ f3()被解析为(f1()+ f2())+ f3( )由于operator +的从左到右的关联性,但可以在运行时首先 ...
  • 保证?:的评估顺序:首先计算第一个操作数,然后根据第一个操作数是否为真来计算第二个或第三个操作数。 您主要对运算符优先级/关联性与评估顺序之间的关系感到困惑。 他们扮演不同的角色。 前者决定运算符的分组方式,而后者决定首先计算哪个子表达式。 考虑表达式a * b + c * d ,优先规则意味着它等同于(a * b) + (c * d) 。 但是保证编译器会在c * d之前评估a * b吗? 答案是否定的,在本例中,运算符+不保证评估顺序。 条件运算符?:是具有指定评估顺序的少数运算符之一。 (其余的是&& ...
  • 从c ++标准第5条, 重载运算符遵守第5章中规定的语法规则。 第5节规定了运算符的优先级和关联性。 From c++ standard clause 5, Overloaded operators obey the rules for syntax specified in Clause 5. Where clause 5 specifies operator precedence and associativity.
  • 这可以做到......但需要付出一些努力。 基本思想是使用右移运算符来创建和更新推迟实际计算的新类型对象。 例如,假设您的变量如上:A,B,C,D和E都是Actual类型的对象。 我们将介绍一个新类Deferred,它是由一个实例的实例上的rshift操作产生的。 Deferred还实现了rshift运算符,它更新对象并返回自身。 (顺便说一下,对于这个答案的其余部分,我假设A,B,C,D和E是不可变的,并且rshift操作产生一个新对象。) F = A >> B >> C >> D >> E 计算如.. ...
  • 优先级和关联性是不同的概念,但从技术上讲,C和C ++标准没有指定。 相反,他们给出语法规则来推断表达式的结构。 相关规则是: conditional-expression: logical-or-expression logical-or-expression ? expression : assignment-expression expression: assignment-expression expression , assignment-expression ...
  • 这是一个gcc扩展。 x = a ? : b; 几乎是一样的 x = a ? a : b; 除了a只被评估一次这一事实,如果a有任何副作用或评价昂贵,这是有用的。 It's a gcc extension. x = a ? : b; is almost the same as x = a ? a : b; except for the fact that a is only evaluated once, which is useful if a has any side effects or is ...
  • 从最新的公开草案 5.6乘法运算符[expr.mul] 1乘法运算符*,/和%组从左到右。 multiplicative-expression: pm-expression multiplicative-expression * pm-expression multiplicative-expression / pm-expression multiplicative-expression % pm-expression 所以解析会像这样: int res = x / y * z / t; int res ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)