Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"not found: value classOf" error when building scala in IntelliJ IDEA, but builds correctly in maven

I have written a small piece of test code and am compiling it with IntelliJ IDEA 12 CE

import com.twitter.common.zookeeper.ZooKeeperClient
import org.mockito.Mockito

    class MyResourceSpec { 
      val zkClient = mock(classOf[ZooKeeperClient])
      ...
    }

I get the following error:

not found: value classOf
  val zkClient = mock(classOf[ZooKeeperClient])
                 ^

However I am able to build the project successfully using mvn compile. Also, I have another test file in the same directory "MyOtherResourceSpec.scala" which contains the exact same lines of code.

Any thoughts on why this doesn't build correctly in IDEA?

Things I've tried:

  • A coworker suggested that IDEA might not recognize it as a scala file, and I've tried clicking on the top-level project and then clicking Maven > reimport.

  • Restarting IntelliJ

  • Copying all imports from "MyOtherResourceSpec.scala" in case something was missing

  • using Mockito.mock(classOf[ZooKeeperClient])

like image 878
Ann Kilzer Avatar asked Jul 11 '13 21:07

Ann Kilzer


1 Answers

Okay, I solved this by clicking File > Invalidate Caches and restarting IntelliJ. Then I did not need to import Predef.classOf.

I also had to remove the following import statement:

import scala.Predef.String
like image 73
Ann Kilzer Avatar answered Nov 15 '22 05:11

Ann Kilzer