Scala import not working - object is not a member of package, sbt preppends current package namespace in imports

后端 未结 12 2002
死守一世寂寞
死守一世寂寞 2020-12-14 14:28

I have an issue when trying to import in scala. The object Database exists under com.me.project.database but when I try to import it:



        
12条回答
  •  借酒劲吻你
    2020-12-14 15:03

    I had a similar situation, which was failing in both IntelliJ and maven on the command line. I went to apply the suggested temp fix (adding _root_) but intellij was glitching so bad that wasn't even possible.

    Eventually I noticed that I had mis-created a package so that it repeated the whole path of the package. That meant that the directory my class was in had a subfolder called "com", and the start of my file looked like:

    package com.mycompany.mydept.myproject.myfunctionality.sub1
    
    import com.holdenkarau.spark.testing.DataFrameSuiteBase 
    

    where I had another package called com.mycompany.mydept.myproject.myfunctionality.sub1.com.mycompany.mydept.myproject.myfunctionality.sub2

    And the compiler was looking for "holdenkarau" under com.mycompany.mydept.myproject.myfunctionality.com and failing.

提交回复
热议问题