首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么子项目不能识别依赖关系?

为什么子项目不能识别依赖关系?
EN

Stack Overflow用户
提问于 2019-09-19 02:41:00
回答 1查看 35关注 0票数 0

我定义了两个子项目,如下所示:

代码语言:javascript
复制
val Http4sVersion = "0.21.0-M4"
val CirceVersion = "0.12.1"
val Specs2Version = "4.7.0"
val LogbackVersion = "1.2.3"
val ScalaTestVersion = "3.0.8"
val TestContainerVersion = "1.11.3"
val KafkaTestContainerVersion = "1.11.3"
val ConfigVersion = "1.3.4"
val SpringVersion = "5.1.8.RELEASE"
val CatsVersion = "2.0.0"


lazy val settings = Seq(
  organization := "com.sweetsoft",
  name := "connector",
  scalaVersion := "2.13.0",
  addCompilerPlugin("org.typelevel" %% "kind-projector" % "0.10.3"),
  addCompilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.0"),
  scalacOptions ++= Seq(
    "-deprecation",
    "-encoding", "UTF-8",
    "-language:higherKinds",
    "-language:postfixOps",
    "-feature",
    "-Xfatal-warnings",
  ),
  scalacOptions in(Compile, console) ~= {
    _.filterNot(Set("-Xlint"))
  }

)

lazy val dependencies = Seq(
  "org.http4s" %% "http4s-blaze-server" % Http4sVersion,
  "org.http4s" %% "http4s-blaze-client" % Http4sVersion,
  "org.http4s" %% "http4s-circe" % Http4sVersion,
  "org.http4s" %% "http4s-dsl" % Http4sVersion,
  "io.circe" %% "circe-generic" % CirceVersion,
  "ch.qos.logback" % "logback-classic" % LogbackVersion,
  "org.typelevel" %% "cats-core" % CatsVersion,
  "com.typesafe" % "config" % ConfigVersion % "test",
  "org.scalactic" %% "scalactic" % ScalaTestVersion % "test",
  "org.scalatest" %% "scalatest" % ScalaTestVersion % "test",
  "org.testcontainers" % "testcontainers" % TestContainerVersion % "test",
  "org.testcontainers" % "kafka" % KafkaTestContainerVersion % "test",
  "org.springframework" % "spring-core" % SpringVersion % "test",
  "org.typelevel" %% "cats-laws" % CatsVersion % "test",
  "com.github.alexarchambault" %% "scalacheck-shapeless_1.14" % "1.2.3" % "test",
  "org.scalacheck" %% "scalacheck" % "1.14.0" % "test"
)



lazy val global = project
  .in(file("."))
  .settings(
    settings,
    libraryDependencies ++= dependencies
  )
  .aggregate(core, serversupervisor)


lazy val core = (project in file("core"))
  .settings(settings)


lazy val serversupervisor = (project in file("serversupervisor"))
  .settings(settings)
  .dependsOn(core)

如您所见,这两个子项目分别是core和serversupervisor。

问题是,这两个子项目无法识别依赖关系:

我使用的是Intellj,正如你所看到的,它不能识别依赖关系。我做错了什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-09-19 03:02:23

libraryDependencies ++= dependencies放入settings

globalcoreserversupervisor是三个不同的子项目。它们可以有不同的库依赖项。目前您可以将它们添加到global中,但不能添加到coreserversupervisor中。

或者,您可以将libraryDependencies ++= dependencies移动到GlobalThisBuild范围,而不是特定的子项目范围。您可以在顶部添加

代码语言:javascript
复制
ThisBuild / libraryDependencies ++= dependencies

甚至是

代码语言:javascript
复制
Global / libraryDependencies ++= dependencies

https://www.scala-sbt.org/1.x/docs/Multi-Project.html

https://www.scala-sbt.org/1.x/docs/Scopes.html

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57999020

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档