注入构造函数时出错,Play + Scala的java.lang.ExceptionInInitializerError

时间:2016-12-23 04:53:32

标签: java scala playframework aws-sdk

  • Mac OSX 10.11.6
  • Scala版本2.11.8
  • aws-java-sdk 1.11.57
  • Play Framework 2.5.10

我是Scala和Play Framework的新手。

我有一个要注入控制器的后续类。

reader.close();
writer.close();

控制器

class BoardRepositoryImpl extends BoardRepository {

  private val tableName = "tyo_boards"

  private val table = DynamoDBProvider.db.getTable(tableName)

  override def findAll: List[Board] = {

    val hashCondition = new Condition()
      .withComparisonOperator(ComparisonOperator.EQ)
      .withAttributeValueList(new AttributeValue("841120161129"))

    table.scan(new ScanSpec())
      .asScala
      .toList
      .map( i => new Board(
        i.getString(BoardRepository.codeDate),
        i.getList(BoardRepository.withLimit)
          .asScala
          .toList,
        i.getString(BoardRepository.time)
      )
    )
  }

}

object BoardRepository {
  val codeDate = "code_date"
  val withLimit = "with_limit"
  val time = "time"
}

结果是

@Singleton
class BoardsController @Inject()(repository: BoardRepositoryImpl) extends Controller {

  def index = Action {
    val boards = repository.findAll

    Ok(views.html.boards(boards))
  }

}

老实说,我不知道为什么会这样。

0 个答案:

没有答案