我创建了一个包含3个不同模块的项目。第一个称为http
,第二个称为algebra
。我已将它们连接到sbt
文件中的一个文件中,但是当我想使用algebra
中http
中的类时,则无法导入它们,因为它们彼此看不见。
这是我的sbt
文件:
lazy val commonSettings = Seq(
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-core" % CatsVersion,
"org.typelevel" %% "cats-effect" % "1.2.0",
"org.typelevel" %% "cats-tagless-macros" % "0.2.0",
"org.typelevel" %% "cats-mtl-core" % "0.5.0",
)
)
lazy val root = project.in(file(".")).aggregate(http, domain, algebra)
.settings(commonSettings)
.settings(libraryDependencies ++= Seq(
"org.tpolecat" %% "doobie-core" % DoobieVersion,
"org.tpolecat" %% "doobie-h2" % DoobieVersion,
"org.tpolecat" %% "doobie-scalatest" % DoobieVersion,
"org.tpolecat" %% "doobie-hikari" % DoobieVersion,
))
lazy val http = (project in file("http"))
.dependsOn(algebra)
.settings(commonSettings)
.settings(
name := "my-http",
libraryDependencies ++= Seq(
"io.circe" %% "circe-generic" % CirceVersion,
"io.circe" %% "circe-literal" % CirceVersion,
"io.circe" %% "circe-generic-extras" % CirceVersion,
"io.circe" %% "circe-parser" % CirceVersion,
"io.circe" %% "circe-java8" % CirceVersion,
"io.circe" %% "circe-config" % CirceConfigVersion,
"org.http4s" %% "http4s-blaze-server" % Http4sVersion,
"org.http4s" %% "http4s-circe" % Http4sVersion,
"org.http4s" %% "http4s-dsl" % Http4sVersion,
))
lazy val domain = project.in(file("domain"))
lazy val algebra = (project in file("algebra"))
.settings(commonSettings)
.settings(
name := "my-algebra",
)
我试图刷新所有项目,但是没有用。
class MyRoutes[F[_]: Effect](services: MyService[F]) extends Http4sDsl[F]{...}
类MyRoutes
在http模块中,MyService
在代数模块中。错误是Cannot find declaration to go to
上的MyService
。
我该如何解决?
答案 0 :(得分:1)
好的,我解决了这个问题。这是我的愚蠢错误。我尚未将目录标记为MyService
的源根目录。因此,在http
模块中我看不到此类。