Scala构建没有找到依赖项

Posted

技术标签:

【中文标题】Scala构建没有找到依赖项【英文标题】:Scala build not finding dependencies 【发布时间】:2018-01-29 16:36:41 【问题描述】:

我正在尝试使用 scala 对 SOAP 服务进行概念验证。当我运行sbt compile 时,我收到一个未找到依赖项的错误。行号不是很好,但第一个错误是在下面以“59”开头的行上,它试图转到http://repo1.maven.org/maven2/java-cup。这应该是java_cup,因为我自己导航到了网址:http://repo1.maven.org/maven2/java_cup/。这种未解决的依赖似乎级联到下面的其他错误。

我的问题很简单,为什么 sbt 和/或 ivy 解析 url 不正确?我应该怎么做才能解决这个问题?

1   [info] Loading project definition from /Users/USER/Documents/scalaWorkspace/geoipExample/scalageoipsoap/project
2   [info] Set current project to SimpleSoap (in build file:/Users/USER/Documents/scalaWorkspace/geoipExample/scalageoipsoap/)
3   [info] Updating file:/Users/USER/Documents/scalaWorkspace/geoipExample/scalageoipsoap/root...
[info] Resolving java-cup#java-cup;0.0 ...
55      [warn]  module not found: java-cup#java-cup;0.0
56  [warn] ==== local: tried
57  [warn]   /Users/USER/.ivy2/local/java-cup/java-cup/0.0/ivys/ivy.xml
58  [warn] ==== public: tried
59  [warn]   https://repo1.maven.org/maven2/java-cup/java-cup/0.0/java-cup-0.0.pom
60  [warn] ==== local-preloaded-ivy: tried
61  [warn]   /Users/USER/.sbt/preloaded/java-cup/java-cup/0.0/ivys/ivy.xml
62  [warn] ==== local-preloaded: tried
63  [warn]   file:////Users/USER/.sbt/preloaded/java-cup/java-cup/0.0/java-cup-0.0.pom
[info] Resolving JLex#JLex;0.0 ...
66  [warn]  module not found: JLex#JLex;0.0
67  [warn] ==== local: tried
68  [warn]   /Users/USER/.ivy2/local/JLex/JLex/0.0/ivys/ivy.xml
69  [warn] ==== public: tried
70  [warn]   https://repo1.maven.org/maven2/JLex/JLex/0.0/JLex-0.0.pom
71  [warn] ==== local-preloaded-ivy: tried
72  [warn]   /Users/USER/.sbt/preloaded/JLex/JLex/0.0/ivys/ivy.xml
73  [warn] ==== local-preloaded: tried
74  [warn]   file:////Users/USER/.sbt/preloaded/JLex/JLex/0.0/JLex-0.0.pom
[info] Resolving org.opensymphony#quartz;1.6.0 ...
77  [warn]  module not found: org.opensymphony#quartz;1.6.0
78  [warn] ==== local: tried
79  [warn]   /Users/USER/.ivy2/local/org.opensymphony/quartz/1.6.0/ivys/ivy.xml
80  [warn] ==== public: tried
81  [warn]   https://repo1.maven.org/maven2/org/opensymphony/quartz/1.6.0/quartz-1.6.0.pom
82  [warn] ==== local-preloaded-ivy: tried
83  [warn]   /Users/USER/.sbt/preloaded/org.opensymphony/quartz/1.6.0/ivys/ivy.xml
84  [warn] ==== local-preloaded: tried
85  [warn]   file:////Users/USER/.sbt/preloaded/org/opensymphony/quartz/1.6.0/quartz-1.6.0.pom
[info] Resolving net.sf.saxon#saxon;8.9 ...
88  [warn]  module not found: net.sf.saxon#saxon;8.9
89  [warn] ==== local: tried
90  [warn]   /Users/USER/.ivy2/local/net.sf.saxon/saxon/8.9/ivys/ivy.xml
91  [warn] ==== public: tried
92  [warn]   https://repo1.maven.org/maven2/net/sf/saxon/saxon/8.9/saxon-8.9.pom
93  [warn] ==== local-preloaded-ivy: tried
94  [warn]   /Users/USER/.sbt/preloaded/net.sf.saxon/saxon/8.9/ivys/ivy.xml
95  [warn] ==== local-preloaded: tried
96  [warn]   file:////Users/USER/.sbt/preloaded/net/sf/saxon/saxon/8.9/saxon-8.9.pom
[info] Resolving net.sf.saxon#saxon-dom;8.9 ...
99  [warn]  module not found: net.sf.saxon#saxon-dom;8.9
100 [warn] ==== local: tried
101 [warn]   /Users/USER/.ivy2/local/net.sf.saxon/saxon-dom/8.9/ivys/ivy.xml
102 [warn] ==== public: tried
103 [warn]   https://repo1.maven.org/maven2/net/sf/saxon/saxon-dom/8.9/saxon-dom-8.9.pom
104 [warn] ==== local-preloaded-ivy: tried
105 [warn]   /Users/USER/.sbt/preloaded/net.sf.saxon/saxon-dom/8.9/ivys/ivy.xml
106 [warn] ==== local-preloaded: tried
107 [warn]   file:////Users/USER/.sbt/preloaded/net/sf/saxon/saxon-dom/8.9/saxon-dom-8.9.pom
[info] Resolving net.sf.saxon#saxon-xqj;8.9 ...
110 [warn]  module not found: net.sf.saxon#saxon-xqj;8.9
111 [warn] ==== local: tried
112 [warn]   /Users/USER/.ivy2/local/net.sf.saxon/saxon-xqj/8.9/ivys/ivy.xml
113 [warn] ==== public: tried
114 [warn]   https://repo1.maven.org/maven2/net/sf/saxon/saxon-xqj/8.9/saxon-xqj-8.9.pom
115 [warn] ==== local-preloaded-ivy: tried
116 [warn]   /Users/USER/.sbt/preloaded/net.sf.saxon/saxon-xqj/8.9/ivys/ivy.xml
117 [warn] ==== local-preloaded: tried
118 [warn]   file:////Users/USER/.sbt/preloaded/net/sf/saxon/saxon-xqj/8.9/saxon-xqj-8.9.pom
[info] Resolving org.wso2.uri.template#wso2-uri-templates;1.0.0 ...
121 [warn]  module not found: org.wso2.uri.template#wso2-uri-templates;1.0.0
122 [warn] ==== local: tried
123 [warn]   /Users/USER/.ivy2/local/org.wso2.uri.template/wso2-uri-templates/1.0.0/ivys/ivy.xml
124 [warn] ==== public: tried
125 [warn]   https://repo1.maven.org/maven2/org/wso2/uri/template/wso2-uri-templates/1.0.0/wso2-uri-templates-1.0.0.pom
126 [warn] ==== local-preloaded-ivy: tried
127 [warn]   /Users/USER/.sbt/preloaded/org.wso2.uri.template/wso2-uri-templates/1.0.0/ivys/ivy.xml
128 [warn] ==== local-preloaded: tried
129 [warn]   file:////Users/USER/.sbt/preloaded/org/wso2/uri/template/wso2-uri-templates/1.0.0/wso2-uri-templates-1.0.0.pom
[info] Resolving org.wso2.caching#wso2caching-core;3.4.0 ...
132 [warn]  module not found: org.wso2.caching#wso2caching-core;3.4.0
133 [warn] ==== local: tried
134 [warn]   /Users/USER/.ivy2/local/org.wso2.caching/wso2caching-core/3.4.0/ivys/ivy.xml
135 [warn] ==== public: tried
136 [warn]   https://repo1.maven.org/maven2/org/wso2/caching/wso2caching-core/3.4.0/wso2caching-core-3.4.0.pom
137 [warn] ==== local-preloaded-ivy: tried
138 [warn]   /Users/USER/.sbt/preloaded/org.wso2.caching/wso2caching-core/3.4.0/ivys/ivy.xml
139 [warn] ==== local-preloaded: tried
140 [warn]   file:////Users/USER/.sbt/preloaded/org/wso2/caching/wso2caching-core/3.4.0/wso2caching-core-3.4.0.pom
[info] Resolving org.wso2.eventing#wso2eventing-api;2.1 ...
143 [warn]  module not found: org.wso2.eventing#wso2eventing-api;2.1
144 [warn] ==== local: tried
145 [warn]   /Users/USER/.ivy2/local/org.wso2.eventing/wso2eventing-api/2.1/ivys/ivy.xml
146 [warn] ==== public: tried
147 [warn]   https://repo1.maven.org/maven2/org/wso2/eventing/wso2eventing-api/2.1/wso2eventing-api-2.1.pom
148 [warn] ==== local-preloaded-ivy: tried
149 [warn]   /Users/USER/.sbt/preloaded/org.wso2.eventing/wso2eventing-api/2.1/ivys/ivy.xml
150 [warn] ==== local-preloaded: tried
151 [warn]   file:////Users/USER/.sbt/preloaded/org/wso2/eventing/wso2eventing-api/2.1/wso2eventing-api-2.1.pom
[info] Resolving jline#jline;2.14.1 ...
168 [warn]  ::::::::::::::::::::::::::::::::::::::::::::::
169 [warn]  ::          UNRESOLVED DEPENDENCIES         ::
170 [warn]  ::::::::::::::::::::::::::::::::::::::::::::::
171 [warn]  :: java-cup#java-cup;0.0: not found
172 [warn]  :: JLex#JLex;0.0: not found
173 [warn]  :: org.opensymphony#quartz;1.6.0: not found
174 [warn]  :: net.sf.saxon#saxon;8.9: not found
175 [warn]  :: net.sf.saxon#saxon-dom;8.9: not found
176 [warn]  :: net.sf.saxon#saxon-xqj;8.9: not found
177 [warn]  :: org.wso2.uri.template#wso2-uri-templates;1.0.0: not found
178 [warn]  :: org.wso2.caching#wso2caching-core;3.4.0: not found
179 [warn]  :: org.wso2.eventing#wso2eventing-api;2.1: not found
180 [warn]  ::::::::::::::::::::::::::::::::::::::::::::::
181 [warn] 
182 [warn]  Note: Unresolved dependencies path:
183 [warn]      JLex:JLex:0.0
184 [warn]        +- org.apache.synapse:synapse-securevault:2.1.0
185 [warn]        +- org.apache.synapse:synapse-commons:2.1.0
186 [warn]        +- org.apache.synapse:synapse-tasks:2.1.0
187 [warn]        +- org.apache.synapse:synapse-core:2.1.0 (/Users/USER/Documents/scalaWorkspace/geoipExample/scalageoipsoap/build.sbt#L12)
188 [warn]        +- com.example:simplesoap_2.12:0.1.0-SNAPSHOT
189 [warn]      org.wso2.eventing:wso2eventing-api:2.1
190 [warn]        +- org.apache.synapse:synapse-securevault:2.1.0
191 [warn]        +- org.apache.synapse:synapse-commons:2.1.0
192 [warn]        +- org.apache.synapse:synapse-tasks:2.1.0
193 [warn]        +- org.apache.synapse:synapse-core:2.1.0 (/Users/USER/Documents/scalaWorkspace/geoipExample/scalageoipsoap/build.sbt#L12)
194 [warn]        +- com.example:simplesoap_2.12:0.1.0-SNAPSHOT
195 [warn]      net.sf.saxon:saxon:8.9
196 [warn]        +- org.apache.synapse:synapse-securevault:2.1.0
197 [warn]        +- org.apache.synapse:synapse-commons:2.1.0
198 [warn]        +- org.apache.synapse:synapse-tasks:2.1.0
199 [warn]        +- org.apache.synapse:synapse-core:2.1.0 (/Users/USER/Documents/scalaWorkspace/geoipExample/scalageoipsoap/build.sbt#L12)
200 [warn]        +- com.example:simplesoap_2.12:0.1.0-SNAPSHOT
201 [warn]      org.opensymphony:quartz:1.6.0
202 [warn]        +- org.apache.synapse:synapse-securevault:2.1.0
203 [warn]        +- org.apache.synapse:synapse-commons:2.1.0
204 [warn]        +- org.apache.synapse:synapse-tasks:2.1.0
205 [warn]        +- org.apache.synapse:synapse-core:2.1.0 (/Users/USER/Documents/scalaWorkspace/geoipExample/scalageoipsoap/build.sbt#L12)
206 [warn]        +- com.example:simplesoap_2.12:0.1.0-SNAPSHOT
207 [warn]      org.wso2.caching:wso2caching-core:3.4.0
208 [warn]        +- org.apache.synapse:synapse-securevault:2.1.0
209 [warn]        +- org.apache.synapse:synapse-commons:2.1.0
210 [warn]        +- org.apache.synapse:synapse-tasks:2.1.0
211 [warn]        +- org.apache.synapse:synapse-core:2.1.0 (/Users/USER/Documents/scalaWorkspace/geoipExample/scalageoipsoap/build.sbt#L12)
212 [warn]        +- com.example:simplesoap_2.12:0.1.0-SNAPSHOT
213 [warn]      net.sf.saxon:saxon-dom:8.9
214 [warn]        +- org.apache.synapse:synapse-securevault:2.1.0
215 [warn]        +- org.apache.synapse:synapse-commons:2.1.0
216 [warn]        +- org.apache.synapse:synapse-tasks:2.1.0
217 [warn]        +- org.apache.synapse:synapse-core:2.1.0 (/Users/USER/Documents/scalaWorkspace/geoipExample/scalageoipsoap/build.sbt#L12)
218 [warn]        +- com.example:simplesoap_2.12:0.1.0-SNAPSHOT
219 [warn]      java-cup:java-cup:0.0
220 [warn]        +- org.apache.synapse:synapse-securevault:2.1.0
221 [warn]        +- org.apache.synapse:synapse-commons:2.1.0
222 [warn]        +- org.apache.synapse:synapse-tasks:2.1.0
223 [warn]        +- org.apache.synapse:synapse-core:2.1.0 (/Users/USER/Documents/scalaWorkspace/geoipExample/scalageoipsoap/build.sbt#L12)
224 [warn]        +- com.example:simplesoap_2.12:0.1.0-SNAPSHOT
225 [warn]      net.sf.saxon:saxon-xqj:8.9
226 [warn]        +- org.apache.synapse:synapse-securevault:2.1.0
227 [warn]        +- org.apache.synapse:synapse-commons:2.1.0
228 [warn]        +- org.apache.synapse:synapse-tasks:2.1.0
229 [warn]        +- org.apache.synapse:synapse-core:2.1.0 (/Users/USER/Documents/scalaWorkspace/geoipExample/scalageoipsoap/build.sbt#L12)
230 [warn]        +- com.example:simplesoap_2.12:0.1.0-SNAPSHOT
231 [warn]      org.wso2.uri.template:wso2-uri-templates:1.0.0
232 [warn]        +- org.apache.synapse:synapse-securevault:2.1.0
233 [warn]        +- org.apache.synapse:synapse-commons:2.1.0
234 [warn]        +- org.apache.synapse:synapse-tasks:2.1.0
235 [warn]        +- org.apache.synapse:synapse-core:2.1.0 (/Users/USER/Documents/scalaWorkspace/geoipExample/scalageoipsoap/build.sbt#L12)
236 [warn]        +- com.example:simplesoap_2.12:0.1.0-SNAPSHOT
237 sbt.ResolveException: unresolved dependency: java-cup#java-cup;0.0: not found
238 unresolved dependency: JLex#JLex;0.0: not found
239 unresolved dependency: org.opensymphony#quartz;1.6.0: not found
240 unresolved dependency: net.sf.saxon#saxon;8.9: not found
241 unresolved dependency: net.sf.saxon#saxon-dom;8.9: not found
242 unresolved dependency: net.sf.saxon#saxon-xqj;8.9: not found
243 unresolved dependency: org.wso2.uri.template#wso2-uri-templates;1.0.0: not found
244 unresolved dependency: org.wso2.caching#wso2caching-core;3.4.0: not found
245 unresolved dependency: org.wso2.eventing#wso2eventing-api;2.1: not found
246     at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:313)
247     at sbt.IvyActions$$anonfun$updateEither$1.apply(IvyActions.scala:191)
248     at sbt.IvyActions$$anonfun$updateEither$1.apply(IvyActions.scala:168)
249     at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:156)
250     at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:156)
251     at sbt.IvySbt$$anonfun$withIvy$1.apply(Ivy.scala:133)
252     at sbt.IvySbt.sbt$IvySbt$$action$1(Ivy.scala:57)
253     at sbt.IvySbt$$anon$4.call(Ivy.scala:65)
254     at xsbt.boot.Locks$GlobalLock.withChannel$1(Locks.scala:93)
255     at xsbt.boot.Locks$GlobalLock.xsbt$boot$Locks$GlobalLock$$withChannelRetries$1(Locks.scala:78)
256     at xsbt.boot.Locks$GlobalLock$$anonfun$withFileLock$1.apply(Locks.scala:97)
257     at xsbt.boot.Using$.withResource(Using.scala:10)
258     at xsbt.boot.Using$.apply(Using.scala:9)
259     at xsbt.boot.Locks$GlobalLock.ignoringDeadlockAvoided(Locks.scala:58)
260     at xsbt.boot.Locks$GlobalLock.withLock(Locks.scala:48)
261     at xsbt.boot.Locks$.apply0(Locks.scala:31)
262     at xsbt.boot.Locks$.apply(Locks.scala:28)
263     at sbt.IvySbt.withDefaultLogger(Ivy.scala:65)
264     at sbt.IvySbt.withIvy(Ivy.scala:128)
265     at sbt.IvySbt.withIvy(Ivy.scala:125)
266     at sbt.IvySbt$Module.withModule(Ivy.scala:156)
267     at sbt.IvyActions$.updateEither(IvyActions.scala:168)
268     at sbt.Classpaths$$anonfun$sbt$Classpaths$$work$1$1.apply(Defaults.scala:1481)
269     at sbt.Classpaths$$anonfun$sbt$Classpaths$$work$1$1.apply(Defaults.scala:1477)
270     at sbt.Classpaths$$anonfun$doWork$1$1$$anonfun$121.apply(Defaults.scala:1512)
271     at sbt.Classpaths$$anonfun$doWork$1$1$$anonfun$121.apply(Defaults.scala:1510)
272     at sbt.Tracked$$anonfun$lastOutput$1.apply(Tracked.scala:37)
273     at sbt.Classpaths$$anonfun$doWork$1$1.apply(Defaults.scala:1515)
274     at sbt.Classpaths$$anonfun$doWork$1$1.apply(Defaults.scala:1509)
275     at sbt.Tracked$$anonfun$inputChanged$1.apply(Tracked.scala:60)
276     at sbt.Classpaths$.cachedUpdate(Defaults.scala:1532)
277     at sbt.Classpaths$$anonfun$updateTask$1.apply(Defaults.scala:1459)
278     at sbt.Classpaths$$anonfun$updateTask$1.apply(Defaults.scala:1411)
279     at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
280     at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
281     at sbt.std.Transform$$anon$4.work(System.scala:63)
282     at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
283     at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
284     at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
285     at sbt.Execute.work(Execute.scala:237)
286     at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
287     at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
288     at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
289     at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
290     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
291     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
292     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
293     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
294     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
295     at java.lang.Thread.run(Thread.java:748)
296 [error] (*:update) sbt.ResolveException: unresolved dependency: java-cup#java-cup;0.0: not found
297 [error] unresolved dependency: JLex#JLex;0.0: not found
298 [error] unresolved dependency: org.opensymphony#quartz;1.6.0: not found
299 [error] unresolved dependency: net.sf.saxon#saxon;8.9: not found
300 [error] unresolved dependency: net.sf.saxon#saxon-dom;8.9: not found
301 [error] unresolved dependency: net.sf.saxon#saxon-xqj;8.9: not found
302 [error] unresolved dependency: org.wso2.uri.template#wso2-uri-templates;1.0.0: not found
303 [error] unresolved dependency: org.wso2.caching#wso2caching-core;3.4.0: not found
304 [error] unresolved dependency: org.wso2.eventing#wso2eventing-api;2.1: not found

这是我的build.sbt 文件:

import Dependencies._

lazy val root = (project in file(".")).
  settings(
    inThisBuild(List(
      organization := "com.example",
      scalaVersion := "2.12.1",
      version      := "0.1.0-SNAPSHOT"
    )),
    name := "SimpleSoap",
    mainClass := Some("com.example.SimpleMain"),
    libraryDependencies += synapse
  )

这是我的project/Dependencies.scala 文件:

import sbt._

object Dependencies 
  lazy val synapse = "org.apache.synapse" % "synapse-core" % "2.1.0"

【问题讨论】:

【参考方案1】:

我感觉你的 sbt 文件中缺少resolvers section。这将帮助 SBT 确定 jar 存储库的位置。如果您使用的是 nexus/maven 的自定义托管版本,这一点尤其重要。

【讨论】:

以上是关于Scala构建没有找到依赖项的主要内容,如果未能解决你的问题,请参考以下文章

为什么我的作曲家依赖项没有在docker容器中找到但是本机在我的mac上?

使用 shadowJar 和 Scala 依赖项时如何修复丢失的 conf 文件?

是否可以在Scala中模拟/覆盖依赖项/导入?

未找到此依赖项:* core-js/fn/symbol

如何更改尚未设置的 Scala 应用程序中的依赖项版本?

干净的 sbt 项目中的 Scala Play 框架依赖项