相关疑难解决方法(0)

为什么在Play Framework中使用@Singleton而不是Scala的对象?

我一直在玩Play!框架斯卡拉现在将近一年.我目前正在使用2.5.x版.

我知道Play中控制器的发展以及开发人员如何被迫远离静态object路由.

我也知道Guice在游戏中的用法.

如果您下载激活器并运行:

activator new my-test-app play-scala
Run Code Online (Sandbox Code Playgroud)

Activator将为您生成模板项目.我的问题是围绕模板的这个文件.

我的测试,应用程序/应用程序/服务/ Counter.scala

package services

import java.util.concurrent.atomic.AtomicInteger
import javax.inject._

/**
 * This trait demonstrates how to create a component that is injected
 * into a controller. The trait represents a counter that returns a
 * incremented number each time it is called.
 */
trait Counter {
  def nextCount(): Int
}

/**
 * This class is a …
Run Code Online (Sandbox Code Playgroud)

scala object guice playframework

28
推荐指数
2
解决办法
6367
查看次数

标签 统计

guice ×1

object ×1

playframework ×1

scala ×1