Play子项目无法在IntelliJ上导入Play-json类 [英] Play subproject can't import Play-json classes on IntelliJ

查看:355
本文介绍了Play子项目无法在IntelliJ上导入Play-json类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

然而,我已将我的应用程序拆分为子项目,以便更好地进行组织。我的核心子模块是一个播放应用程序无法导入 play.api.libs.json.Json
这是我的构建.sbt

I've split my app into sub-projects for better organization, however. My core sub-module which is a play app can't import play.api.libs.json.Json Here is my build.sbt

# project/Common.scala
import sbt._
import sbt.Keys._

object Common {

  val settings = Seq(
    organization := "com.company.app",
    scalaVersion := "2.12.5"
  )

  val dependencies = new {

    val macwireVersion = "2.3.0"
    val reactiveMongoVersion = "0.13.0-play26"
    val slickVersion = "3.0.3"
    val postgresVersion = "42.2.2"
    val scalatestPlayVersion = "3.1.2"

    val macwire = "com.softwaremill.macwire" %% "macros" % macwireVersion % "provided"
    val reactivemongo = "org.reactivemongo" %% "play2-reactivemongo" % reactiveMongoVersion
    val slick = "com.typesafe.play" %% "play-slick" % slickVersion
    val slickEvolutions = "com.typesafe.play" %% "play-slick-evolutions" % slickVersion
    val postgresql = "org.postgresql" % "postgresql" % postgresVersion
    val scalatestPlay = "org.scalatestplus.play" %% "scalatestplus-play" % scalatestPlayVersion % Test
  }

  lazy val commonDependencies = Seq(
    dependencies.macwire,
    dependencies.reactivemongo,
    dependencies.slick,
    dependencies.slickEvolutions,
    dependencies.postgresql,
    dependencies.scalatestPlay
  )
}


# build.sbt
lazy val core = (project in file("modules/core"))
  .enablePlugins(PlayScala)
  .settings(
    name := "app-core",
    libraryDependencies ++= Common.commonDependencies ++ Seq(
    ),
    Common.settings
  )

lazy val cms = (project in file("modules/cms"))
  .enablePlugins(PlayScala)
  .settings(
    name := "app-cms",
    libraryDependencies ++= Common.commonDependencies,
    Common.settings
  )
  .dependsOn(core % "test->test;compile->compile")
  .aggregate(core)

lazy val api = (project in file("modules/api"))
  .enablePlugins(PlayScala)
  .settings(
    name := "app-api",
    libraryDependencies ++= Common.commonDependencies,
    Common.settings
  )
  .dependsOn(core % "test->test;compile->compile")
  .aggregate(core)

lazy val reporting = (project in file("modules/reporting"))
  .enablePlugins(PlayScala)
  .settings(
    name := "app-reporting",
    libraryDependencies ++= Common.commonDependencies,
    Common.settings
  )
  .dependsOn(core % "test->test;compile->compile")
  .aggregate(core)

lazy val backend = (project in file("."))
  .enablePlugins(PlayScala)
  .settings(
    name := "app-backend",
    libraryDependencies ++= Common.commonDependencies
  )
  .dependsOn(
    core % "test->test;compile->compile",
    cms,
    api,
    reporting
  )
  .aggregate(cms, api, reporting)

我无法在核心模块中为My model User添加隐式Json格式。

I can't add an implicit Json format for My model User in the core module.

对于后端应用程序,我可以导入w / o问题,有什么我在子模块部分缺少这里?

For the backend app, I can import w/o issues, is there something I'm missing here in the submodule part?

谢谢,

推荐答案

仔细检查您是否实际导入 play-json 库,因为在Play 2.6中它是一个独立的库:

Double check if you are actually importing the play-json library because in Play 2.6 it is a standalone library:

libraryDependencies += "com.typesafe.play" %% "play-json" % playVersion

这篇关于Play子项目无法在IntelliJ上导入Play-json类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆