使用仅适用于旧版 Scala 的 Scala 库
我是斯卡拉新手。但是,我使用 Scala 2.9.0 创建了一个中等规模的程序。现在我想使用一个仅适用于 Scala 2.7.7 的开源库。
在我的 Scala 2.9.0 程序中可能使用这个 2.7.7 库吗?我该怎么做呢?我已经看过 sbt 但并没有真正成功。有人有一个 hello world 示例吗?
I am new to Scala. However, I a created a medium size program with Scala 2.9.0. Now I want to use an open source library which is only available for Scala 2.7.7.
Is it possible to use this 2.7.7 library in my Scala 2.9.0 program? How can I do it? I had already a look at sbt but did not really succeed. Has someone a hello world example for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
原则上应该可以为 2.7.7 jar 和自定义包装器使用自定义类加载器。但实际上,由于该库是开源的,因此用 2.9 重新编译它并进行所需的更改很可能会减少工作量。 (通常不会有很多。)
It should be possible in principle using a custom classloader for the 2.7.7 jar and custom wrappers. But practically, since the library is open source, it's very likely that it would be less work to recompile it with 2.9 and make those changes which are required. (There usually aren't many.)
Typesafe 有一个迁移管理器的早期预览版 (http://typesafe.com/technology/migration-manager),它承诺报告并解决二进制不兼容性问题。显然,早期预览仅报告不兼容性,但可能值得一试。
Typesafe has an early preview of a migration manager (http://typesafe.com/technology/migration-manager) which promises to report on and resolve binary incompatibilities. Apparently the early preview only report on incompatibilities, but it might be worth a shot.
最好的方法是使用维护的库或更新代码。
如果您选择第二个选项,请使用标志
-deprecation
和-Xmigration
编译代码。这会告诉您在版本之间需要更改哪些内容。
The best approach would be to either use a maintained library or to update the code.
If you take the second option, compile the code with the flags
-deprecation
and-Xmigration
.This tells you what you need to change between versions.