gpt4 book ai didi

java - GWT 2.6.1 编译时出现数字转换错误

转载 作者:行者123 更新时间:2023-12-02 13:23:01 26 4
gpt4 key购买 nike

在旧项目的迁移过程中,我将 GWT 的版本从 2.0.4 更改为 2.6.1,将 GXT 从 2.2.0 更改为 2.3.1a。当我的模块被编译为 javascript 时,出现以下错误:

'jar:file:/C:/Users/User/.m2/repository/com/google/gwt/gwt-user/2.6.1

/gwt-user-2.6.1.jar!/com/google/gwt/i18n/client/NumberFormat.java'
[INFO] [ERROR] Line 941: Incompatible conditional operand types Number and BigDecimal
[INFO] [ERROR] Line 942: Cannot cast from Number to BigDecimal
[INFO] [ERROR] Line 947: The method valueOf(int) is undefined for the type BigDecimal
[INFO] [ERROR] Line 952: Incompatible conditional operand types Number and BigInteger
[INFO] [ERROR] Line 953: Cannot cast from Number to BigInteger
[INFO] [ERROR] Line 958: The method valueOf(int) is undefined for the type BigInteger

我使用 org.codehaus.mojo 中的 gwt-maven-plugin。认为这可能是由于java版本不兼容,但我尝试了1.5和1.7。

提到的 NumberFormat.java 片段

   public String format(Number number) {
if (number instanceof BigDecimal) {
BigDecimal bigDec = (BigDecimal) number;
boolean isNegative = bigDec.signum() < 0;
if (isNegative) {
bigDec = bigDec.negate();
}
bigDec = bigDec.multiply(BigDecimal.valueOf(multiplier));
StringBuilder buf = new StringBuilder();
buf.append(bigDec.unscaledValue().toString());
format(isNegative, buf, -bigDec.scale());
return buf.toString();
} else if (number instanceof BigInteger) {
BigInteger bigInt = (BigInteger) number;
boolean isNegative = bigInt.signum() < 0;
if (isNegative) {
bigInt = bigInt.negate();
}
bigInt = bigInt.multiply(BigInteger.valueOf(multiplier));
StringBuilder buf = new StringBuilder();
buf.append(bigInt.toString());
format(isNegative, buf, 0);
return buf.toString();
} else if (number instanceof Long) {
return format(number.longValue(), 0);
} else {
return format(number.doubleValue());
}
}

最佳答案

问题在于 Maven 中已弃用的 gwt-math 依赖项。看起来 gwt-math 不再受支持,其内容已移至 gwt-user。

关于java - GWT 2.6.1 编译时出现数字转换错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31982823/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com