播放编译错误无法访问值 <root>.api 中的术语库。当前类路径可能缺少 <root>.api.libs 的定义,
play compile error Cannot access term libs in value <root>.api. The current classpath may be missing a definition for <root>.api.libs,
我有一个名为 myApp
的播放应用程序,其中有一个名为 searching
的子项目。我想访问我的子项目 searching
中的 myApp(根项目)中存在的模型 class。然后我决定创建另一个名为 common
的 sbt 独立项目,在该项目中我将模型 classes 和 运行 包放在上面。它为我创建了一个 jar,然后我将这个 jar 放在我的游戏的子项目 searching
lib 目录中。
现在的问题是,当我尝试编译我的播放项目和子项目播放时,出现了错误:
myApp>activator
[info] Compiling 45 Scala sources to /media/sara/682AA7A32AA76D2E/study/project/Searching/target/scala-2.11/classes...
[error] bad symbolic reference to <root>.play encountered in class file 'Delete.class'.
[error] Cannot access term play in package <root>. The current classpath may be
[error] missing a definition for <root>.play, or Delete.class may have been compiled against a version that's
[error] incompatible with the one found on the current classpath.
[error] bad symbolic reference to play.api encountered in class file 'Delete.class'.
[error] Cannot access term api in value play. The current classpath may be
[error] missing a definition for play.api, or Delete.class may have been compiled against a version that's
[error] incompatible with the one found on the current classpath.
[error] bad symbolic reference to <root>.api.libs encountered in class file 'Delete.class'.
[error] Cannot access term libs in value <root>.api. The current classpath may be
[error] missing a definition for <root>.api.libs, or Delete.class may have been compiled against a version that's
[error] incompatible with the one found on the current classpath.
[trace] Stack trace suppressed: run last testSearching/compile:compile for the full output.
[error] (testSearching/compile:compile) scala.reflect.internal.Types$TypeError: bad symbolic reference to <root>.libs.json encountered in class file 'Delete.class'.
[error] Cannot access term json in value <root>.libs. The current classpath may be
[error] missing a definition for <root>.libs.json, or Delete.class may have been compiled against a version that's
[error] incompatible with the one found on the current classpath.
[error] Total time: 14 s, completed Oct 20, 2015 1:29:37 PM
我正在使用play 2.3.8;我的游戏项目 myApp
具有以下目录结构
-app
--models
---Delete.scala
-Searcing
-src/main/scala
-------Demo.scala
-lib
--common.jar
这里是Delete.scala
的代码
package models
//import play.api.libs.json.Json
import play.api.libs.json._
@SerialVersionUID(1)
case class Delete( var deleteStatusInt : Int = 0 , var deleteReasonInt : Int = 0) extends Serializable {
def getDeleteStatusInt =DeleteStatus(deleteStatusInt)
def getDeleteReasonInt =DeleteReason(deleteReasonInt)
}
object Delete {
implicit val deleteFormat = Json.format[Delete]
}
和Demo.scala没有使用Delete.Scala代码
这里是myApp项目的构建文件
name := """myApp"""
version := "1.0-SNAPSHOT"
lazy val project = (project in file(".")).enablePlugins(PlayScala)
.aggregate(searching)
.dependsOn(searching)
scalaVersion := "2.11.1"
fork in run := true
javaOptions in run ++= Seq("-J-Xms1G", "-J-Xmx2G")
val appDependencies = Seq(
// Add your project dependencies here,
"org.scalatestplus" %% "play" % "1.2.0" % "test"
)
lazy val searching = project
libraryDependencies ++= Seq(""org.apache.lucene" % "lucene-expressions" % "4.10.4",
"com.typesafe.akka" %% "akka-actor" % "2.3.6",
)
这里是搜索子项目的构建文件
name := """searching"""
version := "1.0-SNAPSHOT"
scalaVersion := "2.11.1"
libraryDependencies ++= Seq("org.apache.lucene" % "lucene-expressions" % "4.10.4",
"com.typesafe.akka" %% "akka-actor" % "2.3.6")
和我创建的独立sbt项目,有如下结构
common
-src/main/scala
--models
---Delete.scala
这里是 Delete.scala
的代码
package models
//import play.api.libs.json.Json
import play.api.libs.json._
@SerialVersionUID(1)
case class Delete( var deleteStatusInt : Int = 0 , var deleteReasonInt : Int = 0) extends Serializable {
def getDeleteStatusInt =DeleteStatus(deleteStatusInt)
def getDeleteReasonInt =DeleteReason(deleteReasonInt)
}
object Delete {
implicit val deleteFormat = Json.format[Delete]
}
这里是普通项目build.sbt
name := "common"
version := "1.0-SNAPSHOT"
organization := "models"
scalaVersion := "2.11.1"
publishMavenStyle := true
libraryDependencies ++= Seq("org.apache.lucene" % "lucene-expressions" % "4.10.4",
//"com.typesafe.play" % "play-json_2.11" % "2.3.8",
"com.typesafe.play" % "play_2.11" % "2.3.8",
"com.typesafe.akka" %% "akka-actor" % "2.3.6"
)
请帮帮我
我通过在 searching
build.sbt 文件
中添加播放库依赖项解决了这个问题
name := """searching"""
version := "1.0-SNAPSHOT"
scalaVersion := "2.11.1"
libraryDependencies ++= Seq("org.apache.lucene" % "lucene-expressions" % "4.10.4",
"com.typesafe.play" % "play_2.11" % "2.3.8",
"com.typesafe.akka" %% "akka-actor" % "2.3.6")
出现问题是因为我没有添加与使用 jar 的项目中使用的库相同的库,因此在 seraching
项目 build.sbt 中添加这些库解决了问题
我有一个名为 myApp
的播放应用程序,其中有一个名为 searching
的子项目。我想访问我的子项目 searching
中的 myApp(根项目)中存在的模型 class。然后我决定创建另一个名为 common
的 sbt 独立项目,在该项目中我将模型 classes 和 运行 包放在上面。它为我创建了一个 jar,然后我将这个 jar 放在我的游戏的子项目 searching
lib 目录中。
现在的问题是,当我尝试编译我的播放项目和子项目播放时,出现了错误:
myApp>activator
[info] Compiling 45 Scala sources to /media/sara/682AA7A32AA76D2E/study/project/Searching/target/scala-2.11/classes...
[error] bad symbolic reference to <root>.play encountered in class file 'Delete.class'.
[error] Cannot access term play in package <root>. The current classpath may be
[error] missing a definition for <root>.play, or Delete.class may have been compiled against a version that's
[error] incompatible with the one found on the current classpath.
[error] bad symbolic reference to play.api encountered in class file 'Delete.class'.
[error] Cannot access term api in value play. The current classpath may be
[error] missing a definition for play.api, or Delete.class may have been compiled against a version that's
[error] incompatible with the one found on the current classpath.
[error] bad symbolic reference to <root>.api.libs encountered in class file 'Delete.class'.
[error] Cannot access term libs in value <root>.api. The current classpath may be
[error] missing a definition for <root>.api.libs, or Delete.class may have been compiled against a version that's
[error] incompatible with the one found on the current classpath.
[trace] Stack trace suppressed: run last testSearching/compile:compile for the full output.
[error] (testSearching/compile:compile) scala.reflect.internal.Types$TypeError: bad symbolic reference to <root>.libs.json encountered in class file 'Delete.class'.
[error] Cannot access term json in value <root>.libs. The current classpath may be
[error] missing a definition for <root>.libs.json, or Delete.class may have been compiled against a version that's
[error] incompatible with the one found on the current classpath.
[error] Total time: 14 s, completed Oct 20, 2015 1:29:37 PM
我正在使用play 2.3.8;我的游戏项目 myApp
具有以下目录结构
-app
--models
---Delete.scala
-Searcing
-src/main/scala
-------Demo.scala
-lib
--common.jar
这里是Delete.scala
的代码package models
//import play.api.libs.json.Json
import play.api.libs.json._
@SerialVersionUID(1)
case class Delete( var deleteStatusInt : Int = 0 , var deleteReasonInt : Int = 0) extends Serializable {
def getDeleteStatusInt =DeleteStatus(deleteStatusInt)
def getDeleteReasonInt =DeleteReason(deleteReasonInt)
}
object Delete {
implicit val deleteFormat = Json.format[Delete]
}
和Demo.scala没有使用Delete.Scala代码
这里是myApp项目的构建文件
name := """myApp"""
version := "1.0-SNAPSHOT"
lazy val project = (project in file(".")).enablePlugins(PlayScala)
.aggregate(searching)
.dependsOn(searching)
scalaVersion := "2.11.1"
fork in run := true
javaOptions in run ++= Seq("-J-Xms1G", "-J-Xmx2G")
val appDependencies = Seq(
// Add your project dependencies here,
"org.scalatestplus" %% "play" % "1.2.0" % "test"
)
lazy val searching = project
libraryDependencies ++= Seq(""org.apache.lucene" % "lucene-expressions" % "4.10.4",
"com.typesafe.akka" %% "akka-actor" % "2.3.6",
)
这里是搜索子项目的构建文件
name := """searching"""
version := "1.0-SNAPSHOT"
scalaVersion := "2.11.1"
libraryDependencies ++= Seq("org.apache.lucene" % "lucene-expressions" % "4.10.4",
"com.typesafe.akka" %% "akka-actor" % "2.3.6")
和我创建的独立sbt项目,有如下结构
common
-src/main/scala
--models
---Delete.scala
这里是 Delete.scala
的代码package models
//import play.api.libs.json.Json
import play.api.libs.json._
@SerialVersionUID(1)
case class Delete( var deleteStatusInt : Int = 0 , var deleteReasonInt : Int = 0) extends Serializable {
def getDeleteStatusInt =DeleteStatus(deleteStatusInt)
def getDeleteReasonInt =DeleteReason(deleteReasonInt)
}
object Delete {
implicit val deleteFormat = Json.format[Delete]
}
这里是普通项目build.sbt
name := "common"
version := "1.0-SNAPSHOT"
organization := "models"
scalaVersion := "2.11.1"
publishMavenStyle := true
libraryDependencies ++= Seq("org.apache.lucene" % "lucene-expressions" % "4.10.4",
//"com.typesafe.play" % "play-json_2.11" % "2.3.8",
"com.typesafe.play" % "play_2.11" % "2.3.8",
"com.typesafe.akka" %% "akka-actor" % "2.3.6"
)
请帮帮我
我通过在 searching
build.sbt 文件
name := """searching"""
version := "1.0-SNAPSHOT"
scalaVersion := "2.11.1"
libraryDependencies ++= Seq("org.apache.lucene" % "lucene-expressions" % "4.10.4",
"com.typesafe.play" % "play_2.11" % "2.3.8",
"com.typesafe.akka" %% "akka-actor" % "2.3.6")
出现问题是因为我没有添加与使用 jar 的项目中使用的库相同的库,因此在 seraching
项目 build.sbt 中添加这些库解决了问题