Problem when importing package in scala
Suppose I have such packages:
package test
package test.views
package test.others
package views
Now in a scala file,开发者_JS百科 I want to import test._
and views._
(not test.views._
), so I write:
import test._
import views._
But when I use some classes under views._
, it reports type xxx not found
, unless I change views
package to another name.
What should I do now?
You can switch package import order (theoretically it should work):
import views._
import test._
Or you can be more precise in views
import:
import _root_.views._
Here's yet another way (though using _root_
is the surest way to go):
import test.{views => testviews, _}
import views._
精彩评论