表达式类型DslEntry必须符合SBT文件中的Def.SettingsDefinition行enablePlugins(JavaServerAppPackaging)

时间:2016-03-11 11:47:35

标签: intellij-idea sbt

我在第Expression type DslEntry must conform to Def.SettingsDefinition in SBT file行收到了消息enablePlugins(JavaServerAppPackaging)我尝试刷新项目,但没有帮助。整个sbt文件主要由lightbend(以前的类型安全)激活器生成,如下所示

import NativePackagerHelper._

name := """ping-backend"""

version := "2.4.0"

scalaVersion := "2.11.7"

libraryDependencies ++= Seq(
  "com.typesafe.akka" %% "akka-actor" % "2.4.0",
  "com.typesafe.play" %% "play-json" % "2.4.6",
  "org.igniterealtime.smack" % "smack-java7" % "4.1.0",
  "org.igniterealtime.smack" % "smack-tcp" % "4.1.0",
  "org.igniterealtime.smack" % "smack-im" % "4.1.0",
  "org.igniterealtime.smack" % "smack-extensions" % "4.1.0"
)

enablePlugins(JavaServerAppPackaging)

mainClass in Compile := Some("sample.hello.Main")

mappings in Universal ++= {
  // optional example illustrating how to copy additional directory
  directory("scripts") ++
  // copy configuration files to config directory
  contentOf("src/main/resources").toMap.mapValues("config/" + _)
}

// add 'config' directory first in the classpath of the start script,
// an alternative is to set the config file locations via CLI parameters
// when starting the application
scriptClasspath := Seq("../config/") ++ scriptClasspath.value

在命令行中运行activator runsbt run项目运行时。我甚至可以从Intellij构建和运行它,所以这更不方便,然后是一个错误,但我仍然宁愿让它解决。有人可以帮我这个吗?

2 个答案:

答案 0 :(得分:5)

我通过 File-> close project 选项关闭了项目,并从主项目和子项目中删除了所有project/target/.idea/。然后,我重新打开intelliJ,并通过 File-> New->从现有资源中进行项目->从外部模型中导入项目->选择项目目录-> sbt 重新导入。

我认为问题出在错误的进口方式上。正确的导入方式已将其修复。

答案 1 :(得分:1)

错误来自intellij的sbt插件https://github.com/JetBrains/intellij-sbt/blob/master/idea-plugin/src/main/scala/org/jetbrains/sbt/language/SbtAnnotator.scala#L41

试试这个

lazy val root = (project in file("."))
  .disablePlugins(JavaServerAppPackaging)

或者

val foo = disablePlugins(JavaServerAppPackaging)