Playframework Project无法访问Play mulit模块项目中的依赖项?
我一直在尝试将我的游戏项目分为几个模块。我跟着。一切都进行得很顺利,我进行了工作测试 在我重写主项目中的一个控制器以使用模块中的服务之后,我开始出现大量错误 Play似乎找不到某些依赖项。我犯了这个错误Playframework Project无法访问Play mulit模块项目中的依赖项?,playframework,sbt,playframework-2.2,Playframework,Sbt,Playframework 2.2,我一直在尝试将我的游戏项目分为几个模块。我跟着。一切都进行得很顺利,我进行了工作测试 在我重写主项目中的一个控制器以使用模块中的服务之后,我开始出现大量错误 Play似乎找不到某些依赖项。我犯了这个错误 object ws is not a member of package play.api.libs import play.api.libs.ws.WS 当我转到该文件时,它能够找到play.libs.WS,但不能找到play.api.libs.WS.WS 我的Build.scala如下所
object ws is not a member of package play.api.libs
import play.api.libs.ws.WS
当我转到该文件时,它能够找到play.libs.WS,但不能找到play.api.libs.WS.WS
我的Build.scala如下所示:
val srcMain = Seq(
scalaSource in Compile <<= (sourceDirectory in Compile)(identity),
javaSource in Compile <<= (sourceDirectory in Compile)(identity),
resourceDirectory in Compile <<= (sourceDirectory / "conf")(identity),
scalaSource in Test <<= (sourceDirectory in Test)(identity),
parallelExecution in Test := false
)
lazy val modules = Seq(mod)
def projectToRef(p: Project): ProjectReference = LocalProject(p.id)
lazy val moduleRefs = modules map projectToRef
lazy val mod = Project("mod", file("modules/mod"), settings = buildSettings ++ srcMain)
.settings(
libraryDependencies ++= Seq(
/* Some dependencies */
)
)
lazy val main = play.Project(appName, appVersion, appDependencies, settings = Resolvers.all)
.dependsOn(api)
lazy val api = Project("api", file("modules/api"), settings = buildSettings ++ srcMain).settings(
libraryDependencies ++= Seq(
cache, apache
)
) aggregate (moduleRefs: _*)
override def rootProject = Some(main)
val mainSettings = Seq(
scalaSource in Compile := sourceDirectory in Compile,
javaSource in Compile := sourceDirectory in Compile,
resourceDirectory in Compile := sourceDirectory / "conf",
scalaSource in Test := sourceDirectory in Test,
parallelExecution in Test := false
)
lazy val mod = (project in file("modules/mod")).settings(buildSettings ++ mainSettings: _*).settings(
libraryDependencies ++= Seq(
/* Some dependencies */
)
)
lazy val main = play.Project(appName, appVersion, appDependencies, settings = Resolvers.all)
.dependsOn(api)
lazy val api = (project in file("modules/api")).settings(buildSettings ++ mainSettings: _*).settings(
libraryDependencies ++= Seq(
cache, apache
)
) aggregate mod
override def rootProject = Some(main)
您的project/build.scala实际上可以如下所示:
val srcMain = Seq(
scalaSource in Compile <<= (sourceDirectory in Compile)(identity),
javaSource in Compile <<= (sourceDirectory in Compile)(identity),
resourceDirectory in Compile <<= (sourceDirectory / "conf")(identity),
scalaSource in Test <<= (sourceDirectory in Test)(identity),
parallelExecution in Test := false
)
lazy val modules = Seq(mod)
def projectToRef(p: Project): ProjectReference = LocalProject(p.id)
lazy val moduleRefs = modules map projectToRef
lazy val mod = Project("mod", file("modules/mod"), settings = buildSettings ++ srcMain)
.settings(
libraryDependencies ++= Seq(
/* Some dependencies */
)
)
lazy val main = play.Project(appName, appVersion, appDependencies, settings = Resolvers.all)
.dependsOn(api)
lazy val api = Project("api", file("modules/api"), settings = buildSettings ++ srcMain).settings(
libraryDependencies ++= Seq(
cache, apache
)
) aggregate (moduleRefs: _*)
override def rootProject = Some(main)
val mainSettings = Seq(
scalaSource in Compile := sourceDirectory in Compile,
javaSource in Compile := sourceDirectory in Compile,
resourceDirectory in Compile := sourceDirectory / "conf",
scalaSource in Test := sourceDirectory in Test,
parallelExecution in Test := false
)
lazy val mod = (project in file("modules/mod")).settings(buildSettings ++ mainSettings: _*).settings(
libraryDependencies ++= Seq(
/* Some dependencies */
)
)
lazy val main = play.Project(appName, appVersion, appDependencies, settings = Resolvers.all)
.dependsOn(api)
lazy val api = (project in file("modules/api")).settings(buildSettings ++ mainSettings: _*).settings(
libraryDependencies ++= Seq(
cache, apache
)
) aggregate mod
override def rootProject = Some(main)
我不明白你为什么要在mainSettings中进行重新分配?你能分享一下主要设置背后的想法吗?您认为play.api.libs.ws.ws如何应用于您的项目?谁带进来的?您是否应该将ws-Play模块作为依赖项添加到main或api中?您是否无意中更改了播放版本?你能给我们看一下你的版本定义吗?你肯定没有改变播放版本。你现在使用的播放版本是2.2?你还可以添加project/plugins.sbt吗?添加了plugins.sbt。看起来你有一个play java项目,而不是play scalaIt,它应该指定在哪里找到源文件。好吧,我确实理解这些设置的含义以及你在语法上做什么,但我不明白你为什么这么做。你能在GitHub上分享这个项目吗?这样可以更容易地帮助你缩小这个问题?不用担心。我回应了上面的另一位评论。问题在于依赖关系。