How to use just one scala library for maven/eclipse/scala

I have configured a project to use scala/maven/Eclipse. Because I need a scala library on the build path and scalatest also uses its own scala library I receive this warning :

More than one scala library found in the build path, all with compatible versions. This is not an optimal configuration, try to limit to one scala library in the build path.

I don't think I can remove this warning as I need both libraries - one for Maven, the other for Eclipse. This doesn't seem to be causing any problems so will I just have to accept it? Is there an alternate configuration which uses just one scala library for Maven & Eclipse?

If I remove the scala library from the project I receive the error:

Cannot find Scala library on the classpath. Verify your build path!

For some reason Eclipse requires the scala library to be on the build path even though it is already available as a Maven dependency.


There is nothing to worry about. Eclipse warns you that you have several scala-library.jar s on your classpath, but as long as they are the same version, it doesn't matter.

If one of them diverged (for instance, by bumping the Scala version number in your pom file), you'd be in trouble: depending on the classpath order, the IDE will pick up classes from one or the other, and you might get different results when building on the command line.

Coming back to your setup, you could

  • remove the Scala Library classpath container from your Eclipse projects, leaving just the jar that maven adds.
  • ignore the warning

  • Venturing a guess here, are you using the Eclipse Indigo pre-installed with Scala 2.9 and the corresponding Scala plugin? If that's the reason you need to use that library, perhaps consider using Eclipse Juno? That's what I use and it works quite well with both the milestone and the nightly builds

    链接地址: http://www.djcxy.com/p/66616.html

    上一篇: Scala和Java在默认的Eclipse中使用Maven

    下一篇: 如何为maven / eclipse / scala使用一个scala库