Scala 无法导入类路由器。在播放2.5时在ApplicationLoader中路由
我在迁移到Scala上玩2.5时遇到了问题。我不得不开始使用DependencyInjection,在阅读了所有PlayFramework2.5迁移文档并完成了所有相应的实现之后,我遇到了一个奇怪的问题。Play表示类路由应该使用新的DependencyInjection模式自动生成,但当我试图在自定义ApplicationLoader中导入该类时,编译器告诉我无法解析符号“router”。下面是我的部分代码,希望你能帮助我,谢谢Scala 无法导入类路由器。在播放2.5时在ApplicationLoader中路由,scala,playframework,dependency-injection,Scala,Playframework,Dependency Injection,我在迁移到Scala上玩2.5时遇到了问题。我不得不开始使用DependencyInjection,在阅读了所有PlayFramework2.5迁移文档并完成了所有相应的实现之后,我遇到了一个奇怪的问题。Play表示类路由应该使用新的DependencyInjection模式自动生成,但当我试图在自定义ApplicationLoader中导入该类时,编译器告诉我无法解析符号“router”。下面是我的部分代码,希望你能帮助我,谢谢 import controllers.Assets import
import controllers.Assets
import controllers.api.clients.ClientsController
import play.api.ApplicationLoader.Context
import play.api._
import play.api.libs.ws.ahc.AhcWSComponents
import router.Routes
class AppLoader extends ApplicationLoader {
def load(context: Context) = {
LoggerConfigurator(context.environment.classLoader).foreach {
_.configure(context.environment)
}
new AppComponents(context).application
}
}
class AppComponents(context: Context) extends BuiltInComponentsFromContext(context) with AhcWSComponents {
lazy val clientsController: ClientsController = new ClientsController(wsClient)
lazy val assets: Assets = new Assets(httpErrorHandler)
lazy val router = new Routes(
httpErrorHandler,
clientsController,
assets
)
}
检查以下各项:
build.sbt
包含routesGenerator:=InjectedRoutesGenerator
sbt
中执行playcileeverything
,并在IDE中刷新项目它是指导入时的符号路由器还是te lazy val?