简体   繁体   English

SBT传递依赖性解决冲突

[英]SBT transitive dependency resolution conflict

I have a problem in SBT resolving transitive dependencies. 我在SBT解决传递依赖性方面存在问题。

The error is: 错误是:

java.lang.NoSuchMethodError: com.vividsolutions.jts.index.strtree.STRtree.queryBoundary()Ljava/util/List

Geospark is using jts2geojson https://github.com/bjornharrtell/jts2geojson/blob/master/pom.xml which references jts in version 1.14 , but this is excluded and they use a custom artifact as a replacement. Geospark正在使用jts2geojson https://github.com/bjornharrtell/jts2geojson/blob/master/pom.xml ,它引用了1.14版本中的jts,但这被排除在外,它们使用自定义工件作为替代。 It is called JTSPlus which still lives in the com.vividsolutions namespace and provides some additional methods, ie the one which is missing above. 它被称为JTSPlus ,它仍然存在于com.vividsolutions命名空间中,并提供了一些其他方法,即上面缺少的方法。

The latest geotools 17 is using jts in version 1.13 https://github.com/geotools/geotools/blob/master/pom.xml#L752-L754 最新的geotools 17在版本1.13使用jts https://github.com/geotools/geotools/blob/master/pom.xml#L752-L754

I need to replace com.vividsolution.jts from geotools with org.datasyslab.jtsplus which offers additional but required functionality how can I achieve this? 我需要更换com.vividsolution.jts从geotools org.datasyslab.jtsplus它提供额外的,但所需的功能我怎样才能做到这一点?

In maven: 在maven中:

<dependency>
            <groupId>org. geotools </groupId>
            <artifactId> geotools </artifactId>
            <version>YOURVERSION</version>
            <exclusions>
                <exclusion>
            <groupId>com.vividsolutions</groupId>
            <artifactId>jts</artifactId>
                </exclusion>
            </exclusions>
</dependency>

should work, but for SBT using 应该工作,但对于SBT使用

libraryDependencies ++= Seq(
  "org.geotools" % "gt-main" % geotools,
  "org.geotools" % "gt-arcgrid" % geotools,
  "org.geotools" % "gt-process-raster" % geotools)
  .map(_.excludeAll(
    ExclusionRule(organization = "com.vividsolution", artifact = "jts")
  ))

did not fix it. 没有解决它。 Actually, whe using the dependencyGraph, I can see SBT is still applying the regular jts in version 1.13 to the whole project. 实际上,使用dependencyGraph时,我可以看到SBT仍在将1.13版本中的常规jts应用于整个项目。

How can I fix the dependencies to properly exclude the original JTS version? 如何修复依赖项以正确排除原始JTS版本?

My build.sbt looks like 我的build.sbt看起来像

lazy val geotools = "17.0"

resolvers += "osgeo" at "http://download.osgeo.org/webdav/geotools"
resolvers += "boundless" at "http://repo.boundlessgeo.com/main"
resolvers += "imageio" at "http://maven.geo-solutions.it"
resolvers += Resolver.mavenLocal

libraryDependencies ++= Seq(
  "org.geotools" % "gt-main" % geotools,
  "org.geotools" % "gt-arcgrid" % geotools,
  "org.geotools" % "gt-process-raster" % geotools)
  .map(_.excludeAll(
    ExclusionRule(organization = "com.vividsolution", artifact = "jts")
  ))

libraryDependencies ++= Seq(
  "org.datasyslab" % "geospark" % "0.6.1-snapshot"
)

Why is SBT NOT excluding these libraries despite using excludes? 尽管使用排除,为什么SBT不排除这些库? mentioned in the comments that allDependencies instead of libraryDependencies needs to be used. 在评论中提到需要使用allDependencies而不是libraryDependencies I think this is required due to the transitive problems. 我认为由于传递性问题,这是必需的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM