gpt4 book ai didi

playframework-2.2 - 使用 Play!Framework 2.2 子项目

转载 作者:行者123 更新时间:2023-12-03 23:49:08 25 4
gpt4 key购买 nike

我试图在子项目中拆分我的 Play!Framework 2.2 项目,但我很难弄清楚。

这是我的文件夹结构:

MyProject/
| - app/
| --- controllers/ # containing some main controllers
| --- views/ # resulting views
| - build.sbt # see after
| - conf/
| --- application.conf
| --- routes
| --- modules/ # My modules folder, aka sub projects
| -------- common/
| ------------ app/
| --------------- models/ # The models
| --------------- utils/
| -------- api/
| -------- web/
| ------------ app/ # some controllers/views
| ------------ conf/ # routes mainly
| ------------ app/ # some controllers/views
| ------------ conf/ # routes mainly

(我简化了它)。

routes文件:
# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~

# Home page
GET / controllers.StaticPages.index()

# Web
-> /html/v1 web.Routes

# API
-> /api/v1 api.Routes

网络路由:
# HTML Engine renderer
# ~~~~~~~~~~~~~~~~~~~~

GET /users controllers.Users.list()

api.routes :
# API
# ~~~~~~~~~~~~~~~~~~~~

GET /users controllers.Users.list()

最后,我的 build.sbt
import play.Project._

name := "My project"

version := "1.0-alpha"

libraryDependencies ++= Seq(
javaJdbc,
javaEbean,
cache,
"mysql" % "mysql-connector-java" % "5.1.25",
"com.typesafe" %% "play-plugins-mailer" % "2.2.0"
)

play.Project.playJavaSettings

lazy val root = project.in(file("."))
.dependsOn(common, web, api)
.aggregate(common, web, api)

lazy val web = project.in(file("modules/web"))
.dependsOn(common)

lazy val api = project.in(file("modules/api"))
.dependsOn(common)

lazy val common = project.in(file("modules/common"))

清理/编译和运行时,我面临这个错误:

not found: value web In /path/to/project/conf/routes at line 20. -> /html/v1 web.Routes



如果我删除 ->在主 routes文件,播放!找不到共同的包 utils。

所以我猜常见的,web 和 api 没有加载,但为什么呢?

更新

由于@James-roper 帮助我发现了问题,我创建了一个 Github 存储库,其中显示了一个带有子项目的简单 Play!Framework 2.2 项目。你可以在这里找到它: https://github.com/cnicodeme/play2.2-subproject

最佳答案

您的子项目需要使用不同的包名称,目前它们是冲突的。

关于playframework-2.2 - 使用 Play!Framework 2.2 子项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19403101/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com