我正在使用Scalatra开始一个新项目,在尝试构建流程时,编译器会说:
[info] Compiling 13 Scala sources to /home/mauricio/projects/scala/id2-search-proxy/target/scala-2.11/classes...
[error] missing or invalid dependency detected while loading class file 'ScalatraServlet.class'.
[error] Could not access term servlet in package javax,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'ScalatraServlet.class' was compiled against an incompatible version of javax.
[error] missing or invalid dependency detected while loading class file 'ScalatraServlet.class'.
[error] Could not access type HttpServlet in value javax.http,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'ScalatraServlet.class' was compiled against an incompatible version of javax.http.
[error] missing or invalid dependency detected while loading class file 'DynamicScope.class'.
[error] Could not access term servlet in package javax,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'DynamicScope.class' was compiled against an incompatible version of javax.
[error] missing or invalid dependency detected while loading class file 'RequestResponseScope.class'.
[error] Could not access term servlet in package javax,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'RequestResponseScope.class' was compiled against an incompatible version of javax.
[error] missing or invalid dependency detected while loading class file 'ScalatraContext.class'.
[error] Could not access term servlet in package javax,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'ScalatraContext.class' was compiled against an incompatible version of javax.
[error] missing or invalid dependency detected while loading class file 'DynamicScope.class'.
[error] Could not access type HttpServletResponse in value javax.http,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'DynamicScope.class' was compiled against an incompatible version of javax.http.
[error] missing or invalid dependency detected while loading class file 'DynamicScope.class'.
[error] Could not access type HttpServletRequest in value javax.http,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'DynamicScope.class' was compiled against an incompatible version of javax.http.
[error] missing or invalid dependency detected while loading class file 'SessionSupport.class'.
[error] Could not access term servlet in package javax,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'SessionSupport.class' was compiled against an incompatible version of javax.
[error] missing or invalid dependency detected while loading class file 'SessionSupport.class'.
[error] Could not access type HttpSession in value javax.http,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'SessionSupport.class' was compiled against an incompatible version of javax.http.
[error] missing or invalid dependency detected while loading class file 'ServletApiImplicits.class'.
[error] Could not access term servlet in package javax,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'ServletApiImplicits.class' was compiled against an incompatible version of javax.
[error] missing or invalid dependency detected while loading class file 'Route.class'.
[error] Could not access term servlet in package javax,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'Route.class' was compiled against an incompatible version of javax.
[error] missing or invalid dependency detected while loading class file 'ScalatraServlet.class'.
[error] Could not access type ServletConfig in value javax.servlet,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'ScalatraServlet.class' was compiled against an incompatible version of javax.servlet.
[error] missing or invalid dependency detected while loading class file 'ServletApiImplicits.class'.
[error] Could not access type ServletContext in value javax.servlet,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'ServletApiImplicits.class' was compiled against an incompatible version of javax.servlet.
[error] missing or invalid dependency detected while loading class file 'ServletApiImplicits.class'.
[error] Could not access type HttpSession in value javax.http,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'ServletApiImplicits.class' was compiled against an incompatible version of javax.http.
[error] missing or invalid dependency detected while loading class file 'ServletApiImplicits.class'.
[error] Could not access type HttpServletResponse in value javax.http,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'ServletApiImplicits.class' was compiled against an incompatible version of javax.http.
[error] missing or invalid dependency detected while loading class file 'ServletApiImplicits.class'.
[error] Could not access type HttpServletRequest in value javax.http,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'ServletApiImplicits.class' was compiled against an incompatible version of javax.http.
[error] 16 errors found
[error] (compile:compileIncremental) Compilation failed
[error] Total time: 6 s, completed 23/09/2015 13:03:32
我无法在scalatra源代码或我这里的文件中找到这些损坏的引用,所有导入看起来都是正确的。知道这里发生了什么吗?
我的SBT文件是这样的:
name := "id2-search-proxy"
version := "1.0"
scalaVersion := "2.11.7"
lazy val versions = new {
val scalatra = "2.4.0-RC2-2"
val specs2 = "3.6.4-20150916230958-8339115"
}
resolvers ++= Seq(
Resolver.sonatypeRepo("releases"),
"Twitter Maven" at "https://maven.twttr.com"
)
libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.1.3"
libraryDependencies += "com.ning" % "async-http-client" % "1.9.31"
libraryDependencies += "commons-io" % "commons-io" % "2.4"
libraryDependencies += "io.argonaut" %% "argonaut" % "6.1-M4"
libraryDependencies += "oauth.signpost" % "signpost-core" % "1.2.1.2"
libraryDependencies += "oauth.signpost" % "signpost-commonshttp4" % "1.2.1.2"
libraryDependencies += "org.mockito" % "mockito-core" % "1.10.19" % Test
libraryDependencies += "org.specs2" %% "specs2-core" % versions.specs2 % Test
libraryDependencies += "org.specs2" %% "specs2-mock" % versions.specs2 % Test
libraryDependencies += "org.scalatra" %% "scalatra" % versions.scalatra
libraryDependencies += "org.scalatra" %% "scalatra-specs2" % versions.scalatra % Test
resolvers += "twitter-repo" at "http://maven.twttr.com/"
resolvers += "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases"
scalacOptions in Test ++= Seq("-Yrangepos", "-Ylog-classpath")
答案 0 :(得分:2)
由于servlet-api
被设置为提供它将被加载到Idea但在编译期间不可用,直接取决于它修复了问题:
libraryDependencies += "javax.servlet" % "javax.servlet-api" % "3.1.0"