开发者

scala package conflict

开发者 https://www.devze.com 2023-03-11 14:51 出处:网络
I have a library which has root package \"scala\", and now I have a proj开发者_开发百科ect using this library, and I have a sub package named \"com.zjffdu.scala\". And the class file in this package n

I have a library which has root package "scala", and now I have a proj开发者_开发百科ect using this library, and I have a sub package named "com.zjffdu.scala". And the class file in this package needs to import classes from the library. So I have the following import statement.

import scala._

But because this class is also in package "scala", the scala compiler will look for files in current directory rather than the library.

So how can I explicit to tell scala to import classes from the library.

Thanks


Use this:

import _root_.scala._

As you can see it's not very pretty — the best option is probably to avoid naming one of your packages scala.

And by the way — the root scala package is always preimported (though subpackages, of course, are not).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号