SBT 本地依赖问题 - 某些导入不起作用。 (斯卡拉项目)
好吧,我需要将 eclipse 制作的项目转换为 SBT 项目。 尽管如此,当我编译时,一些未解决的依赖关系会导致编译错误。
> compile
[info] Compiling 9 Scala sources to /home/giladhoch/workspace/clever_dropbox/clever_dropbox_manager/target/scala-2.9.0.1/classes...
[error] /home/giladhoch/workspace/clever_dropbox/clever_dropbox_manager/src/main/scala/filesTagSystem/DynamicClassLoader.scala:7: not found: object labels
[error] import labels.FileLabeler
[error] ^
[error] /home/giladhoch/workspace/clever_dropbox/clever_dropbox_manager/src/main/scala/filesTagSystem/DynamicClassLoader.scala:96: value labelFile is not a member of type parameter A
[error] fileLabelers.foreach{ f=> f.labelFile(file).foreach{ s=> tagsList+=s}}
[error] ^
[error] /home/giladhoch/workspace/clever_dropbox/clever_dropbox_manager/src/main/scala/watchDirectory/ServiceManager.scala:9: object StandardWatchEventKind is not a member of package java.nio.file
[error] import java.nio.file.StandardWatchEventKind._
[error] ^
[error] /home/giladhoch/workspace/clever_dropbox/clever_dropbox_manager/src/main/scala/main/clientManager.scala:24: overloaded method constructor Thread with alternatives:
[error] (java.lang.String)java.lang.Thread <and>
[error] (java.lang.Runnable)java.lang.Thread
[error] cannot be applied to (watchDirectory.ServiceManager)
[error] val serviceThread = new Thread(service)
[error] ^
[error] four errors found
[error] {file:/home/giladhoch/workspace/clever_dropbox/clever_dropbox_manager/}default-55f3d0/compile: Compilation failed
[error] Total time: 3 s, completed Sep 15, 2011 4:42:32 AM
如您所见,错误是由两个未解析的导入引起的。 第一个用于 import labels.FileLabeler
,第二个用于 import java.nio.file.StandardWatchEventKind._
好吧,我不知道为什么 java.nio 导入不起作用。 JAVA_HOME 被定义为 java7 文件夹,所以 SBT 不应该知道去那里吗?对于另一个导入,它是本地预编译的类文件。我尝试在 build.sbt
中添加以下内容:
resolvers += Resolver.file("local-lib", file("/home/*path-to-project*/src/main/scala/tagsPluginsDir/")) transactional()
但没有多大帮助...... 那么如何解决这个问题呢?
谢谢, 吉拉德.
well, i needed to convert a project made with eclipse to an SBT project.
still, when i compile, some unresolved dependencies causes compilation errors.
> compile
[info] Compiling 9 Scala sources to /home/giladhoch/workspace/clever_dropbox/clever_dropbox_manager/target/scala-2.9.0.1/classes...
[error] /home/giladhoch/workspace/clever_dropbox/clever_dropbox_manager/src/main/scala/filesTagSystem/DynamicClassLoader.scala:7: not found: object labels
[error] import labels.FileLabeler
[error] ^
[error] /home/giladhoch/workspace/clever_dropbox/clever_dropbox_manager/src/main/scala/filesTagSystem/DynamicClassLoader.scala:96: value labelFile is not a member of type parameter A
[error] fileLabelers.foreach{ f=> f.labelFile(file).foreach{ s=> tagsList+=s}}
[error] ^
[error] /home/giladhoch/workspace/clever_dropbox/clever_dropbox_manager/src/main/scala/watchDirectory/ServiceManager.scala:9: object StandardWatchEventKind is not a member of package java.nio.file
[error] import java.nio.file.StandardWatchEventKind._
[error] ^
[error] /home/giladhoch/workspace/clever_dropbox/clever_dropbox_manager/src/main/scala/main/clientManager.scala:24: overloaded method constructor Thread with alternatives:
[error] (java.lang.String)java.lang.Thread <and>
[error] (java.lang.Runnable)java.lang.Thread
[error] cannot be applied to (watchDirectory.ServiceManager)
[error] val serviceThread = new Thread(service)
[error] ^
[error] four errors found
[error] {file:/home/giladhoch/workspace/clever_dropbox/clever_dropbox_manager/}default-55f3d0/compile: Compilation failed
[error] Total time: 3 s, completed Sep 15, 2011 4:42:32 AM
as you can see, the errors are caused by two unresolved imports.
first one for import labels.FileLabeler
and the second one for import java.nio.file.StandardWatchEventKind._
well, i have no idea why the java.nio import does'nt work. JAVA_HOME is defined to java7 folder, so should'nt SBT supposed to know to look there? and for the other import, well, it's a local precompiled class file. i tried to add in build.sbt
the following:
resolvers += Resolver.file("local-lib", file("/home/*path-to-project*/src/main/scala/tagsPluginsDir/")) transactional()
but it didn't help much...
so how can this be solved?
thanks,
Gilad.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题已解决:
对于外部源文件,我打开了一个新的 sbt 项目并使用了publish-local,因此 jar 最终位于 .ivy2 文件夹中,因此 sbt 现在知道从哪里获取依赖项。
至于 java.nio.file.StandardWatchEventKind 导入,结果发现它只是缺少尾随 s,它应该是: java.nio.file.StandardWatchEventKind*s*
problem has been resolved:
for the outer source files, i opened a new sbt project and used publish-local, so the jars end up in the .ivy2 folder, so sbt now know where to get the dependencies from.
as for the java.nio.file.StandardWatchEventKind import, turns out it just had a missing trailing s, and it should be: java.nio.file.StandardWatchEventKind*s*