[英]Class conflict on different dependencies
我在我的項目的 2 個依賴項上有相同的類。 庫 unit-api-1.0(它是 org.geotools 的依賴項)和 jscience-4.3.1 都有類javax.measure.quantity.Length
。
[INFO] +- org.geotools:gt-shapefile:jar:22.3:compile
[INFO] | +- org.geotools:gt-main:jar:22.3:compile
[INFO] | | +- org.geotools:gt-referencing:jar:22.3:compile
[INFO] | | | +- org.ejml:ejml-ddense:jar:0.34:compile
[INFO] | | | | \- org.ejml:ejml-core:jar:0.34:compile
[INFO] | | | +- commons-pool:commons-pool:jar:1.5.4:compile
[INFO] | | | +- org.geotools:gt-metadata:jar:22.3:compile
[INFO] | | | | \- org.geotools:gt-opengis:jar:22.3:compile
[INFO] | | | | \- systems.uom:systems-common-java8:jar:0.7.2:compile
[INFO] | | | | +- tec.uom:uom-se:jar:1.0.8:compile
[INFO] | | | | | +- javax.measure:unit-api:jar:1.0:compile
[INFO] \- org.jscience:jscience:jar:4.3.1:compile
[INFO] \- org.javolution:javolution:jar:5.2.3:compile
當我嘗試使用 Length 參數化Measure 時,出現錯誤:
[ERROR] error: type argument Length is not within bounds of type-variable Q
[ERROR] where Q is a type-variable:
[ERROR] Q extends Quantity declared in class Measure
基本上兩個接口 Length 都擴展了接口 Quantity,如下所示:
https://www.javadoc.io/static/javax.measure/unit-api/1.0/javax/measure/quantity/Length.html http://jscience.org/api/javax/measure/quantity/Length.html
但是其中一個擴展了數量,而另一個擴展了數量。 不知何故,它們彼此不兼容,編譯器使用了錯誤的,並給了我這個錯誤。
有沒有辦法以某種方式管理這種情況?
GeoTools 升級常見問題解答涵蓋了 20.0 版之后使用 Units 所需的更改。
您需要以下依賴項:
<dependency>
<groupId>systems.uom</groupId>
<artifactId>systems-common-java8</artifactId>
<version>0.7.2</version>
</dependency>
並進行這些更改:
包名稱已更改,導致升級時出現一些常見的搜索和替換:
搜索 javax.measure.unit.Unit 替換 javax.measure.Unit
搜索 ConversionException 替換 IncommensurableException
這是一個已檢查的異常,在 GeoTools 庫的區域中,我們現在返回一個 IllegalArgument 異常。
搜索轉換器 == UnitConverter.IDENTITY 替換 converter.isIdentity()
搜索 javax.measure.unit.NonSI 替換 import si.uom.NonSI
搜索 javax.measure.unit.SI 替換 import si.uom.SI
搜索 SI.METER 替換 SI.METRE
搜索 javax.measure.converter.UnitConverter 替換 javax.measure.UnitConverter
搜索 javax.measure.unit.UnitFormat 替換 import javax.measure.format.UnitFormat
Search Unit.ONE 替換 AbstractUnit.ONE
搜索 Dimensionless.UNIT 替換 AbstractUnit.ONE
搜索 Unit.valueOf(unitString) 替換 Units.parseUnit(unitString)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.