升级lift-mapper版本时,如何解决“无隐式视图”错误?

我有一个旧的scala liftweb项目。我已经有一段时间没有看过,并且正在使用liftweb 2.6映射器和webkit。我想从2.6升级到3.4,并且在更新构建sbt时,出现一堆关于类型不匹配和隐式视图不可用的错误。当我使用mapper .find方法尝试查找某些内容时,通常会发生这种情况。我想知道我做错了什么以及如何解决?

Country.find(By(Country.name,this.country)) match {
      case Full(country) =>
        country.currency_code_id.obj match {
          case Full(currency_code) => currency_code
          case _ => defaultCurrency
        }
      case _ => defaultCurrency
    } 

其中country是当前用户的字段

object country extends MappedString(this,64)
[error] C:\Users\<snip>\User.scala:700:20: No implicit view available from User.this.country.type => String.
[error]     Country.find(By(Country.name,this.country)) match {
[error]                    ^
[error] C:\Users\<snip>\User.scala:702:17: value currency_code_id is not a member of Any
[error]         country.currency_code_id.obj match {
[error]                 ^
[error] C:\Users\<snip>\User.scala:703:39: type mismatch;
[error]  found   : Any
[error]  required: com.postrope.model.CurrencyCode
[error]           case Full(currency_code) => currency_code
[error]                                       ^

Country.scala看起来像

object Country extends Country with KeyedMetaMapper[Long,Country] {

  private val logger = Logger(classOf[Country])
  override def dbTableName = "countries"

}

class Country extends KeyedMapper[Long,Country] {

  def getSingleton = Country // what's the "meta" server
  def primaryKeyField = id

  object id extends MappedLongIndex(this)

  object name extends MappedString(this,512) {
    override def displayName = "Item name"
  }

  object code_2 extends MappedString(this,2)
  object code_3 extends MappedString(this,3);

  object alternative_spellings extends MappedString(this,512)
  object relevancy_booster extends MappedString(this,5)

  object currency_label extends MappedString(this,128)
  object currency_code extends MappedString(this,3)
  object currency_code_id extends MappedLongForeignKey(this,CurrencyCode)

  def flag_ref = "/images/flags/"+code_2+".gif"
}
woshihime 回答:升级lift-mapper版本时,如何解决“无隐式视图”错误?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2568552.html

大家都在问