sbt 库依赖性错误:预期为“)”,但找到了字符串文字

问题描述 投票:0回答:1

我是

sbt
和 Scala 的新手。我正在遵循 入门指南:

打开 build.sbt 并添加以下行:

libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "2.1.1"

这就是我所做的:

val scala3Version = "3.5.2"

lazy val root = project
  .in(file("."))
  .settings(
    name := "encrypt-files",
    version := "0.1.0-SNAPSHOT",
    scalaVersion := scala3Version,
    libraryDependencies += "org.scalameta" %% "munit" % "1.0.0" % Test
    libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "2.1.1"
  )

但是,然后我得到这个编译错误:

')' expected but string literal found.

我做错了什么?

scala sbt
1个回答
0
投票

请注意,设置以逗号分隔。您需要在上一行末尾添加逗号:

                                                                  ⌄
libraryDependencies += "org.scalameta" %% "munit" % "1.0.0" % Test,
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "2.1.1"

顺便说一句,你也可以一次添加多个依赖项,但是它需要

++=
,而不仅仅是
+=

libraryDependencies ++= Seq(
    "org.scalameta" %% "munit" % "1.0.0" % Test,
    "org.scala-lang.modules" %% "scala-parser-combinators" % "2.1.1"
)
© www.soinside.com 2019 - 2024. All rights reserved.