play framework i scala 中的 build.sbt PlayScala 错误

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

这是我的

build.sbt
文件,我收到有关“PlayScala”无法解析的错误
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.19")
这已经在
plugin.sbt
中添加了并且版本没有问题

lazy val root = (project in file("."))
  .enablePlugins(PlayScala)
  .settings(
    name := """play-scala-hello-world-tutorial""",
    organization := "com.example",
    version := "1.0-SNAPSHOT",
    scalaVersion := "2.13.10",
    libraryDependencies ++= Seq(
      "com.google.inject" % "guice" % "5.1.1",
      "org.scalatestplus.play" %% "scalatestplus-play" % "5.1.0" % Test
    ),
    scalacOptions ++= Seq(
      "-feature",
      "-deprecation",
      "-xfatal-warnings"
    )
  )
scala intellij-idea playframework sbt sbt-plugin
1个回答
0
投票
  • 创建新 Play 项目的最佳方式是
sbt new playframework/play-scala-seed.g8

https://www.playframework.com/getting-started

  • 你项目的 sbt 版本是什么?看看
    project/build.properties
    .

使用 sbt 1.7.2-

如果您使用的是 sbt 1.7.3+ (1.8.x),您应该将以下内容添加到

project/plugins.sbt

ThisBuild / libraryDependencySchemes ++= Seq(
  "org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always
)

https://github.com/playframework/playframework/issues/11522

  • 你从哪里得到guice 5.1.1? mvnrepository 知道 5.1.0-

https://mvnrepository.com/artifact/com.google.inject/guice

5.1.1 是快照

resolvers ++= Resolver.sonatypeOssRepos("snapshots"),
libraryDependencies ++= Seq(
  "com.google.inject" % "guice" % "5.1.1-SNAPSHOT",
  ...

https://oss.sonatype.org/content/repositories/snapshots/com/google/inject/guice/

https://oss.sonatype.org/content/groups/public/com/google/inject/guice/

  • 你的 Java 是什么?

JDK 8 是默认的。自 Play 2.8.x 起支持 JDK 11

https://www.playframework.com/documentation/2.8.19/Highlights28#Java-11-support

在 JDK 17 中需要进行一些调整

如果您使用的是 Guice,则必须使用最新版本 ...

https://github.com/playframework/playframework/releases/2.8.15

但是你已经在使用最新的(甚至更新鲜的)Guice 所以这应该没问题。

  • 有时 Play 和 sbt 版本之间可能不兼容

Play scala.tools.nsc.Settings.bootclasspath()NoSuchMethodError()

(但这是在运行时,而不是构建时)。

© www.soinside.com 2019 - 2024. All rights reserved.