Scala:没有实例错误

时间:2016-12-07 12:43:51

标签: scala

斯卡拉新手问题。

我尝试实施lambdista config

获取错误:

没有为config.ExampleConfig.FooConfig找到的ConcreteValue类型的实例

method没有足够的方法参数:(隐式证据$ 1:com.lambdista.config.ConcreteValue [config.ExampleConfig.FooConfig])scala.util.Try [config.ExampleConfig.FooConfig]。未指定的值参数证据$ 1。

示例代码copied from here

package config

import java.io.InputStream
import java.nio.file.Paths

import scala.concurrent.duration._
import scala.util.{Failure, Success, Try}

import com.lambdista.config.exception.{ConfigSyntaxException,    ConversionException, KeyNotFoundException}
import com.lambdista.config._

object ExampleConfig extends App {

val confPath = "src//main//resources//example.conf"
val config: Try[Config] = Config.from(Paths.get(confPath))

case class Greek(alpha: String, beta: Int)

case class FooConfig(
  bar: String, 
  baz: Option[Int], 
  list: List[Int],
  map: Greek,
  mapList: List[Greek], 
  range: Range, 
  duration: Duration,
  missingValue: Option[String]
 )

val fooConfig: Try[FooConfig] = for {
    conf <- config
    result <- conf.as[FooConfig]
  } yield result  
}

Sbt build.sbt

  name := "example"

  version := "1.0"

  scalaVersion := "2.10.5"

  libraryDependencies ++= Seq(
  "com.lambdista" %% "config" % "0.5.0"
  )

   resolvers += Resolver.mavenLocal

输入文件:

  // comment 1
 {
  bar = "hello",
  # comment 2
  baz = 42,
  list = [1, // comment 3
        2, 3],
  map = {
  alpha = "hello",
  beta = 42
  },
  mapList = [
   {
    alpha = "hello",
    beta = 42
   },
  {
    alpha = "world",
    beta = 24
  }
],
 range = 2 to 10 by 2,
 duration = 5 seconds
 }

可能有什么不对?非常感谢

0 个答案:

没有答案