开发者

"is not a member of package" error when importing package in Scala with SBT

(Relative beginner here, please be gentle...)

I've got a Scala program that I can build with sbt. I can (from within sbt) run compile and test-compile with no errors. I've defined a package by putting package com.mycompany.mypackagename at the top of several .scala files. When I do console to get a Scala REPL, this happens:

scala> import com.mycompany.mypackagename._     
<console>:5: error: value mypackagename is not a member of package com.mycompany
       import com.mycompany.mypackag开发者_开发百科ename._

Any variation of this also fails. When I just do import com.mycompany I get no problems.

I thought that running the Scala console from within sbt would properly set the classpath based on the current projects? What (completely obvious) thing am I missing?


I ran into this same problem, and then I realized I was running scala 2.10.0 on commandline, and IDEA was using Scala 2.9.2. So the fix was to change both to use the same version, and:

sbt clean


What will happen if you import actual class name instead of wildcard.

import com.mycompany.mypackagename.ActualClassName
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜