错误:预期的类或对象定义 [英] error: expected class or object definition

查看:95
本文介绍了错误:预期的类或对象定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个(智能代码):

I have this (smart code):

import com.mongodb.casbah.Imports._
import com.mongodb.casbah.util.bson.conversions._
RegisterJodaTimeConversionHelpers() //error

object Main {
  def main(args: Array[String]) {
    val connection = MongoConnection()
  }
}

我得到一个错误:

error: expected class or object definition
RegisterJodaTimeConversionHelpers()

我必须使用此 RegisterJodaTimeConversionHelpers() (2.2. :自动类型转换),但始终会出现此错误消息.有什么想法吗?

I have to use this RegisterJodaTimeConversionHelpers() (2.2. Briefly: Automatic Type Conversions), but there's always this error message. Any ideas?

推荐答案

您必须在可执行代码的地方编写此行代码.相反,在您的main方法中呢?

You have to write this line of code somewhere it can be executed. How about in your main method instead?

object Main {
  def main(args: Array[String]) {
    RegisterJodaTimeConversionHelpers()
    val connection = MongoConnection()
  }
}

这篇关于错误:预期的类或对象定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆