Class 不同依赖的冲突
Class conflict on different dependencies
我在我的项目的 2 个依赖项上有相同的 class。库 unit-api-1.0(它是 org.geotools 的依赖)和 jscience-4.3.1 都有 class 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
但是其中一个扩展了Quantity,而另一个扩展了Quantity。不知何故,它们彼此不兼容,编译器使用了错误的并给我这个错误。
有没有办法以某种方式处理这种情况?
GeoTools upgrade FAQ涵盖了在 20.0 版本之后使用单位所需的更改。
您需要以下依赖项:
<dependency>
<groupId>systems.uom</groupId>
<artifactId>systems-common-java8</artifactId>
<version>0.7.2</version>
</dependency>
并进行以下更改:
Package names have changed, resulting in some common search and replaces when upgrading:
Search javax.measure.unit.Unit replace javax.measure.Unit
Search ConversionException replace IncommensurableException
This is a checked exception, in areas of the GeoTools library where this was found we now return an IllegalArgument exception.
Search converter == UnitConverter.IDENTITY replace converter.isIdentity()
Search javax.measure.unit.NonSI replace import si.uom.NonSI
Search javax.measure.unit.SI replace import si.uom.SI
Search SI.METER replace SI.METRE
Search javax.measure.converter.UnitConverter replace javax.measure.UnitConverter
Search javax.measure.unit.UnitFormat replace import javax.measure.format.UnitFormat
Search Unit.ONE replace AbstractUnit.ONE
Search Dimensionless.UNIT replace AbstractUnit.ONE
Search Unit.valueOf(unitString) replace Units.parseUnit(unitString)
我在我的项目的 2 个依赖项上有相同的 class。库 unit-api-1.0(它是 org.geotools 的依赖)和 jscience-4.3.1 都有 class 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
但是其中一个扩展了Quantity,而另一个扩展了Quantity。不知何故,它们彼此不兼容,编译器使用了错误的并给我这个错误。
有没有办法以某种方式处理这种情况?
GeoTools upgrade FAQ涵盖了在 20.0 版本之后使用单位所需的更改。
您需要以下依赖项:
<dependency>
<groupId>systems.uom</groupId>
<artifactId>systems-common-java8</artifactId>
<version>0.7.2</version>
</dependency>
并进行以下更改:
Package names have changed, resulting in some common search and replaces when upgrading:
Search javax.measure.unit.Unit replace javax.measure.Unit
Search ConversionException replace IncommensurableException
This is a checked exception, in areas of the GeoTools library where this was found we now return an IllegalArgument exception.
Search converter == UnitConverter.IDENTITY replace converter.isIdentity()
Search javax.measure.unit.NonSI replace import si.uom.NonSI
Search javax.measure.unit.SI replace import si.uom.SI
Search SI.METER replace SI.METRE
Search javax.measure.converter.UnitConverter replace javax.measure.UnitConverter
Search javax.measure.unit.UnitFormat replace import javax.measure.format.UnitFormat
Search Unit.ONE replace AbstractUnit.ONE
Search Dimensionless.UNIT replace AbstractUnit.ONE
Search Unit.valueOf(unitString) replace Units.parseUnit(unitString)