关于Scala:尝试使用Scalatra编译项目并失败

Trying to compile a project with Scalatra and failing

我正在使用Scalatra启动一个新项目,当尝试构建该过程时,编译器会说:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
[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文件是这样的:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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")

由于servlet-api设置为,只要将其加载到Idea上,但在编译期间将不可用,直接取决于它来解决此问题:

1
libraryDependencies +="javax.servlet" %"javax.servlet-api" %"3.1.0"