我正在尝试为Play框架构建Scala hello world示例:https://example.lightbend.com/v1/download/play-samples-play-scala-hello-world-tutorial
我得到了这个未解决的依赖项:
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: org.hamcrest#hamcrest-core;1.3: org.hamcrest#hamcrest-core;1.3!hamcrest-core.pom(pom.original) origin location must be absolute: file:/home/sahandz/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.pom
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] Note: Unresolved dependencies path:
[warn] org.hamcrest:hamcrest-core:1.3 (/home/sahandz/comdev/play-samples-play-scala-hello-world-tutorial/build.sbt#L12-13)
[warn] +- junit:junit:4.12
[warn] +- com.typesafe.play:play-test_2.13:2.7.3 ((play.sbt.PlaySettings.serviceSettings) PlaySettings.scala#L67)
[warn] +- org.scalatestplus.play:scalatestplus-play_2.13:4.0.3 (/home/sahandz/comdev/play-samples-play-scala-hello-world-tutorial/build.sbt#L11-12)
[warn] +- com.example:play-scala-seed_2.13:1.0-SNAPSHOT
这是build.sbt文件:
name := """play-scala-seed"""
organization := "com.example"
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayScala)
scalaVersion := "2.11.12" // Previously: 2.13.0
libraryDependencies += guice
libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "4.0.3" % Test
libraryDependencies += "org.hamcrest" % "hamcrest-core" % "1.3" % Test
我已将 scala 版本更改为与我机器上的版本相同:
$ scala -version
Scala code runner version 2.11.12 -- Copyright 2002-2017, LAMP/EPFL
我的 SBT 版本是:
$ sbt sbtVersion
[info] 1.2.8
我的爪哇版本:
$ java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-8u212-b03-0ubuntu1.18.10.1-b03)
OpenJDK 64-Bit Server VM (build 25.212-b03, mixed mode)
还有我的 Maven 版本(如果相关(:
$ mvn -version
Apache Maven 3.6.0
Maven home: /usr/share/maven
Java version: 1.8.0_212, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.18.0-25-generic", arch: "amd64", family: "unix"
此错误是如何发生的?我查看了 maven 存储库,似乎该工件存在,尽管它已被弃用:https://mvnrepository.com/artifact/org.hamcrest/hamcrest-core/1.3
我通过进入~/.ivy2
文件夹并删除jars/org.hamcrest_hamcrest-core-1.3.jar
和cache/org.hamcrest/
来解决问题。任何关于为什么这样做的解释都是值得赞赏的。