gpt4 book ai didi

ubuntu - 在 ubuntu 14.04 服务器下,双数乘法在 Grails 中不起作用

转载 作者:行者123 更新时间:2023-12-02 15:19:43 25 4
gpt4 key购买 nike

我在 Grails 2.2.1 中乘以双数并将其保存为 string .它在本地环境下工作正常(windows 7,jdk 7,tomcat7)但在ubuntu server下不工作(14.04,tomcat7,jdk7)。我无法找出其背后的根本原因。

这里是 error log

public java.lang.Number java.lang.Number#multiply(java.lang.Number).Stacktrace follows:

org.codehaus.groovy.runtime.metaclass.MethodSelectionException: Could not find which method multiply() to invoke from this list:

public java.lang.Number java.lang.Number#multiply(java.lang.Character)
public java.lang.Number java.lang.Number#multiply(java.lang.Number)

at sagoon.ProductsController.addDiamondProduct(ProductsController.groovy:232)

at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:195)

at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

at java.lang.Thread.run(Thread.java:745)
code 摘录
 def today = new Date().clearTime()
def todayGoldPrice = GoldRates.findAllByGoldDate(today)
def category = Categories.get(params.category)
def karigad = Karigads.get(params.karigad)

Double totalDiamondAmount = params.diamondWeight.toDouble() * params.diamondRate.toDouble()

Double totalGoldAmount = params.goldWeight.toDouble() * ( params.goldPercent.toDouble()/100 ) * todayGoldPrice.rate

Double totalMc = params.goldWeight.toDouble() * params.mcPerGram.toDouble()

Double totalStoneAmount = params.stoneWeight.toDouble() * params.stonePricePerCarat.toDouble()

Double totalPurchasePrice = totalDiamondAmount.toDouble() + totalGoldAmount.toDouble() + totalStoneAmount.toDouble() + totalMc.toDouble()

ProductsController.addDiamondProduct
 def addDiamondProduct(){

def today = new Date().clearTime()
def todayGoldPrice = GoldRates.findAllByGoldDate(today)
def category = Categories.get(params.category)
def karigad = Karigads.get(params.karigad)

Double totalDiamondAmount = params.diamondWeight.toDouble() * params.diamondRate.toDouble()
Double totalGoldAmount = params.goldWeight.toDouble() * ( params.goldPercent.toDouble()/100 ) * todayGoldPrice.rate
Double totalMc = params.goldWeight.toDouble() * params.mcPerGram.toDouble()
Double totalStoneAmount = params.stoneWeight.toDouble() * params.stonePricePerCarat.toDouble()
Double totalPurchasePrice = totalDiamondAmount.toDouble() + totalGoldAmount.toDouble() + totalStoneAmount.toDouble() + totalMc.toDouble()

def product = new DiamondProducts(
productCode: params.productCode,
diamondWeight: params.diamondWeight,
diamondRate: params.diamondRate,
totalDiamondAmount: totalDiamondAmount.toString(),
goldWeight: params.goldWeight,
goldKt: params.goldPurity,
goldPercent: params.goldPercent,
totalGoldAmount: totalGoldAmount.toString(),
mcGram: params.mcPerGram,
totalMc: totalMc.toString(),
stoneWeight: params.stoneWeight,
stonePricePerCarat: params.stonePricePerCarat,
totalStoneAmount: totalStoneAmount.toString(),
totalPurchasePrice: totalPurchasePrice.toString(),
salePrice: params.salePrice,
remarks: params.remarks,
description: params.description,
itemNumber: params.itemNumber,
karigad: karigad,
category: category,
status: "notSold",
createdDate: new Date()
)
product.save()

flash.message = "Product Added Successfully."
redirect(action: 'diamondProducts')

}

我在这里做错了什么?

最佳答案

由于工作环境不同,我不认为它会给你这个错误。我已经在 Ubuntu 14.04 上进行了测试。环境,它工作得很好。

您可以在 error log 中查看那个,在run-time groovy 引擎与 multiply 混淆了方法。它无法选择任何一种方法,因为有两个选项可用,这就是它给出 MethodSelectionException 的原因.

public java.lang.Number java.lang.Number#multiply(java.lang.Character)
public java.lang.Number java.lang.Number#multiply(java.lang.Number)

另请查看 code 中的以下行您添加的片段
def todayGoldPrice = GoldRates.findAllByGoldDate(today)
.
.
.
Double totalGoldAmount = params.goldWeight.toDouble() * ( params.goldPercent.toDouble()/100 ) * todayGoldPrice.rate

在您所做的第一行中 findAllByGoldDate查询 Domain class GoldRates . findAllByGoldDate将返回匹配查询条件的对象列表。

在您进行乘法的另一行中,查看您访问 rate 的方式。来自 todayGoldPrice 的字段包含对象列表的集合。我建议您替换 findAllByfindBy如果您想访问 rate字段直接喜欢 todayGoldPrice.rate您在代码中所做的。

请查看它,如果可能的话,在两个环境中使用相同的数据库转储。

关于ubuntu - 在 ubuntu 14.04 服务器下,双数乘法在 Grails 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39608649/

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