从 GitHub 编译 Scala SJSON 时出现问题
我对 SJSON 的第一个版本有疑问(What is a good library for JSON serialization for Scala 2.8.1 for use in Eclipse )我尝试使用,但在我尝试的新版本中,同样的问题仍然存在,所以我不确定如何处理。
这是我遇到问题的一个例子,它从第 50 行开始 https://github.com/ginkel/sjson/blob/master/src/main/scala/sjson/json/Generic.scala:
<#list 2..9 as i>
<#assign typeParams><#list 1..i as j>T${j}<#if i !=j>,</#if></#list></#assign>
def asProduct${i}[S, ${typeParams}](<#list 1..i as j>f${j}: String<#if i != j>,</#if></#list>)(apply : (${typeParams}) => S)(unapply : S => Product${i}[${typeParams}])(implicit <#list 1..i as j>bin${j}: Format[T${j}]<#if i != j>,</#if></#list>) = new Format[S]{
我使用了 EGit (http://www.eclipse.org/egit/) 来获取代码,但是当我尝试编译它我遇到了几个错误,其中两个是:
Description Resource Path Location Type
';' expected but double literal found. Generic.scala /sjson/src/main/scala/sjson/json line 50 Scala Problem
';' expected but '[' found. Generic.scala /sjson/src/main/scala/sjson/json line 53 Scala Problem
那么,我应该如何编译这些错误才能使其工作,而不需要仔细检查和修复代码,因为这似乎是错误的方法。
I had a problem with the first version of SJSON (What is a good library for JSON serialization for Scala 2.8.1 for use in Eclipse) that I tried to use, but with the new version I tried the same problem is still there, so it is something I am not certain how to handle.
This is one example of what I am having problems with, it starts on line 50 at https://github.com/ginkel/sjson/blob/master/src/main/scala/sjson/json/Generic.scala:
<#list 2..9 as i>
<#assign typeParams><#list 1..i as j>T${j}<#if i !=j>,</#if></#list></#assign>
def asProduct${i}[S, ${typeParams}](<#list 1..i as j>f${j}: String<#if i != j>,</#if></#list>)(apply : (${typeParams}) => S)(unapply : S => Product${i}[${typeParams}])(implicit <#list 1..i as j>bin${j}: Format[T${j}]<#if i != j>,</#if></#list>) = new Format[S]{
I used EGit (http://www.eclipse.org/egit/) to get the code, but when I tried to compile it I get several errors, two of which are:
Description Resource Path Location Type
';' expected but double literal found. Generic.scala /sjson/src/main/scala/sjson/json line 50 Scala Problem
';' expected but '[' found. Generic.scala /sjson/src/main/scala/sjson/json line 53 Scala Problem
So, how should I be compiling these so it will work, without going through and fixing the code, as it would seem that that is the wrong approach.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这肯定是 Eclipse 的某种问题,因为我刚刚克隆了存储库并使用 sbt 构建了它,效果很好。
如果你想成功构建这个,我建议你安装 SBT(如果你还没有安装的话)。这对于 Scala 开发来说几乎是必需的。与 Netbeans 和 IntelliJ 集成很容易 - 我不再使用 Eclipse,但我想也可以通过打开 shell 或控制台窗口并在那里运行 SBT 来完成。
一旦您“安装”了 SBT(只是一个 jar 和一个脚本 - http://code .google.com/p/simple-build-tool/),导航到您将 SJSON 克隆到的目录。运行“sbt”。在 sbt 提示符下运行“update”以获取依赖项。运行“编译”来构建。一切都准备好了。
如果您不需要从源代码构建,而只需在您的项目中使用该库,则它位于 Scala Tools 存储库中: http://scala-tools.org/repo-releases/net/debasishg/sjson_2.8.0/ 所以你可以将它添加为 sbt 或 Maven 中的依赖项或常春藤。对于 SBT,这应该有效:
我个人没有使用过这个库。 lift-json 对我来说效果很好。但 sjson 看起来确实值得一看。祝你好运!
It must be some sort of issue with Eclipse because I just cloned the repo and built it with sbt just fine.
If you want to successfully build this, I suggest you install SBT if you haven't already. It really is almost necessary for doing Scala development. It's easy to integrate with Netbeans and IntelliJ - I don't use Eclipse at all any more, but I imagine it can be done there too by opening a shell or console window and running SBT there.
Once you have SBT "installed" (just a jar and a script - http://code.google.com/p/simple-build-tool/), navigate to the directory you cloned SJSON into. Run 'sbt'. At the sbt prompt run 'update' to get the dependencies. Run 'compile' to build. And you're all set.
If you don't need to build from source but just use the library in a project of yours, it's in the Scala Tools repository: http://scala-tools.org/repo-releases/net/debasishg/sjson_2.8.0/ So you can add it as a dependency in sbt or Maven or Ivy. For SBT, this should work:
I haven't personally used this library. lift-json has been working well for me. But sjson does look worth a look. Good luck!