在Play(框架)中成功编译了一个子项目(管理区域)



我想在Play Framework(2.6)中设置一个管理区域作为子项目,所以一直在使用此文档,但遇到了一个编译错误,我无法修复:

〔错误〕。。。conf\routes:15:未找到:value admin

[error]->/admin管理员。路由

这是我的项目结构:

main-project
_build.sbt
_app
_controllers
_models
_views
_conf
_application.conf
_routes
_modules
_admin
_build.sbt
_app
_controllers
_models
_views
_conf
_admin.routes
_project
_build.properties
_plugins.sbt

主项目/build.sbt

import play.sbt.routes.RoutesKeys
name := "main-project"
val defaultResolvers = Seq(
Resolver.sonatypeRepo("snapshots")
)
lazy val commonSettings = Seq(
organization := "com.boardrs",
version := "1.0-SNAPSHOT",
scalaVersion := "2.12.2",
scalacOptions ++= Seq("-feature", "-language:postfixOps"),
resolvers ++= defaultResolvers
)

lazy val admin = (project in file("modules/admin"))
.settings(
commonSettings
).enablePlugins(PlayScala)
lazy val root = (project in file("."))
.settings(
commonSettings
)
.enablePlugins(PlayScala)

routesGenerator := InjectedRoutesGenerator
RoutesKeys.routesImport += "play.modules.reactivemongo.PathBindables._"
libraryDependencies += guice
libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "3.0.0" % Test
libraryDependencies += "com.h2database" % "h2" % "1.4.194"
libraryDependencies += "com.typesafe.play" %% "play-json" % "2.6.0"
libraryDependencies += ws
// Play 2.6.x
libraryDependencies ++= Seq(
"org.reactivemongo" %% "play2-reactivemongo" % "0.12.5-play26"
)

libraryDependencies += "org.webjars" % "bootstrap" % "3.1.1-2"

主项目/模块/admin/build.sbt

name := "admin"
PlayKeys.devSettings += "play.http.router" -> "admin.Routes"

main project/conf/routes(包含错误中引用的行的文件)

# home page
GET     /                   controllers.HomeController.index
->  /admin admin.Routes
GET     /assets/*file       controllers.Assets.at(path="/public", file)

主项目/模块/admin/conf/admin.routes

GET /index                  controllers.admin.HomeController.index()
GET /assets/*file           controllers.admin.Assets.versioned(path="/public/lib/admin", file)

我在这里(在Stack Overflow上)和其他地方仔细查看了解决方案,例如,这个问题非常相似,但答案包含了后来被弃用的技术。我尝试过多种组合,但Play Framework是一个精致的野兽;易受大量配置和兼容性问题的影响,所以我不觉得自己在努力寻找答案。有人能看到我看不到的东西吗?感谢

在您的主项目/build.sbt:中

尝试更改:

lazy val admin = (project in file("admin"))

lazy val admin = (project in file("modules/admin"))

我认为您在主sbt中缺少根项目的dependensOn和aggregateOn。

尝试更改:

lazy val root = (project in file("."))
.settings(
commonSettings
)
.enablePlugins(PlayScala)

lazy val root = (project in file("."))
.settings(
commonSettings
)
.enablePlugins(PlayScala).dependsOn(admin).aggregate(admin)

相关内容

  • 没有找到相关文章

最新更新