问题
How can I use library build against 2.9.2 in project which is built using 2.10.1 ?
In particular I'm trying to use salat and get following exception
sbt.ResolveException: unresolved dependency: com.novus#salat_2.10;1.9.2-SNAPSHOT: not found
at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:214)
at sbt.IvyActions$$anonfun$update$1.apply(IvyActions.scala:122)
at sbt.IvyActions$$anonfun$update$1.apply(IvyActions.scala:121)
at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:114)
at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:114)
at sbt.IvySbt$$anonfun$withIvy$1.apply(Ivy.scala:102)
at sbt.IvySbt.liftedTree1$1(Ivy.scala:49)
at sbt.IvySbt.action$1(Ivy.scala:49)
at sbt.IvySbt$$anon$3.call(Ivy.scala:58)
回答1:
You can't. Major versions of Scala are binary incompatible.
回答2:
You can. Just use OSGi. Use Scala 2.9.x with one bundle, use Scala 2.10.x with other. Work with multiple incompatible binary dependencies within single execution environment is one of the situations for which OSGi was created. Scala jar already packed as bundle. Everything ready.
回答3:
You seem to be using the library version, built against 2.10. The artifact, you are using seems to be incorrect though. In your build.sbt
try changing "com.novus" %% "salat" % "1.9.2-SNAPSHOT"
to "com.novus" %% "salat-core" % "1.9.2-SNAPSHOT"
. Here's the full list of artifacts available for 2.10.
回答4:
This works for me http://pastebin.com/yy6tGYDE
- add
"Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
- remove
"org.mongodb" %% "casbah" % "2.6.0"
possible conflict, salat 1.9.2-SNAPSHOT uses 2.5.0 - change
"com.novus" % "salat-core" % "1.9.2-SNAPSHOT"
to"com.novus" %% "salat" % "1.9.2-SNAPSHOT"
回答5:
You will have to recompile the library against scala 2.10 as the the scala-versions are binary incompatible with each major release. As from 2.9 to 2.10.
来源:https://stackoverflow.com/questions/16581059/how-can-i-use-library-which-is-built-using-2-9-2-in-project-which-is-built-using