简体   繁体   English

Grails货币插件:无法解析金钱类

[英]Grails Currencies Plugin: Unable to resolve class Money

I installed the grails currency plugin. 我安装了grails货币插件。 I want to use the Money type in my grails domain class as such: 我想在我的grails域类中使用Money类型,例如:

class FOO{
...
    Money lunchCost = new Money(amount:0.00, currency:'USD')
    Money dinnerCost = new Money(amount:0.00, currency:'USD')
...
}

I get an error when I compile saying "unable to resolve class Money". 当我说“无法解决金钱类”时,我得到一个错误。 I traced the package heirchy of the Grails Money Plugin and tried to put in: 我跟踪了Grails Money插件的软件包,并尝试放入:

cr.co.arquetipos.currencies.Money breakfastCost = new cr.co.arquetipos.currencies.Money(amount:0.00, currency:'USD')

---- That didn't work either. ----那也不行。

1) When I generated Foo, grails placed the domain class under "projectName.Foo" as it does for every domain class created. 1)当我生成Foo时,grails将域类放在“ projectName.Foo”下,就像创建每个域类一样。 2) I'm using Grails 1.3.5. 2)我正在使用Grails 1.3.5。

Do you have any ideas as to where the Currencies class is so I can include it in the "import <....Money> and get rid of this compilation error? 您是否对Currencies类在哪里有任何想法,以便我可以将其包含在“ import <.... Money>中,并消除此编译错误?”

Same here: The plugin does not integrate with the Grails project, at all. 此处相同:该插件完全不与Grails项目集成。 Nevertheless, it has been installed to ${user.home}/.grails/1.3.5/projects/${project.name}/plugins/currencies-0.3 . 不过,它已安装到${user.home}/.grails/1.3.5/projects/${project.name}/plugins/currencies-0.3

Since the plugin has been last updated in 2008 and doesn't cover too much functionality, I'd suggest to just copy the two domain classes (in the grails-app/domain folder) into your project. 由于该插件的最新更新时间为2008年,并且没有涉及太多功能,因此建议您仅将两个域类(位于grails-app/domain文件夹中)复制到您的项目中。

For an evaluation, you may also want to have a brief look at grails-app/conf and test/integration in the plugin's installation folder. 为了进行评估,您可能还希望简要了解一下该插件的安装文件夹中的grails-app/conftest/integration

Like ataylor says, don't use this plugin, it's broken. 就像ataylor所说的,不要使用此插件,它已经坏了。 Instead use JScience. 而是使用JScience。 Checkout: Best practice to represent Money (value + currency) in Grails 结帐: 在Grails中表示金钱(价值+货币)的最佳做法

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

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