2013-04-11 23 views
0

有與mortageCalc應用演習在Griffon in Action書3.6.1段工作。錯誤的IntelliJ運行格里芬的應用程序,但它從命令提示符

環境:

  • Win 7的專業版,64位
  • IntelliJ IDEA的版本12.1
  • 格里芬-1.2.0 JDK 1.6

我有MortgageCalView

package mortgagecal 

application(title:'Mortgage Calculator', pack:true, locationByPlatform:true) 
     { 
      panel(border: emptyBorder(6)) { 
       gridLayout(rows:4, columns:2, hgap:6, vgap:6) 
       label('Principal:') 
       textField(text: bind(target:model, 'principal', 
         value:'$200,000', 
         validator: model.validatePrincipal, 
         converter: model.convertPrincipal)) 
       label('Interest Rate:') 
       textField(text: bind(target:model, 'monthlyRate', 
         value:'6.5%', 
         validator: model.validateRate, 
         converter: model.convertRate)) 
       label('Term:') 
       textField(text: bind(target:model, 'months', 
         value:'30', 
         validator: model.validateTerm, 
         converter: model.convertTerm)) 
       label('Monthly Payment (P&I):') 
       textField(editable:false, 
         text: bind(source: model, sourceProperty: 'payment', 
           sourceEvent: 'propertyChange', 
           converter: model.convertPayment)) 
      } 
     } 

MortgageCalModel

package mortgagecal 

import groovy.beans.Bindable 
import java.text.NumberFormat 
import java.text.DecimalFormat 

@Bindable 
class MortgageCalModel { 
    float principal 
    float monthlyRate 
    float months 
    float getPayment() { 
     return principal * monthlyRate/
       (1-Math.pow(1/(1+monthlyRate),months)) 
    } 
    private currencyFormat = NumberFormat.currencyInstance 
    private percentFormat = new DecimalFormat('0.00%') 
    def validatePrincipal = { 
     try { 
      float principal = currencyFormat.parse(it) 
      return principal > 0 
     } catch (Exception e) { 
      return false 
     } 
    } 
    def convertPrincipal = currencyFormat.&parse 
    def validateRate = { 
     try { 
      float rate = percentFormat.parse(it) 
      return rate > 0 && rate < 0.30 
     } catch (Exception e) { 
      return false 
     } 
    } 
    def convertRate = { 
     return percentFormat.parse(it)/12 
    } 
    def validateTerm = { 
     try { 
      def term = Float.parseFloat(it) 
      return term > 0 && term < 100 
     } catch (Exception e) { 
      return false 
     } 
    } 
    def convertTerm = { 
     return Float.parseFloat(it) * 12 
    } 
    def convertPayment = { 
     return currencyFormat.format(it) 
    } 
} 

當運行它,我看到錯誤:

捉住:groovy.lang.MissingMethodException:法無簽名: mortgagecal.MortgageCalView.application()是適用於參數 類型:(java.util.LinkedHashMap, mortgagecal.MortgageCalView $ _run_closure1)values:[[title:Mortgage Calculator,pack:true,locationByPlatform:true],...] groovy.lang.Mi ssingMethodException:法無簽名: mortgagecal.MortgageCalView.application()是適用於爭論 類型:(java.util.LinkedHashMap中, mortgagecal.MortgageCalView $ _run_closure1)值:[標題:按揭 計算器,包裝:真, locationByPlatform:真],...]在 mortgagecal.MortgageCalView.run(MortgageCalView.groovy:3)

但是,當我在命令提示符下運行,它工作得很好:

cd D:\work\griffon\mortgageCal> 
griffon run-app 

所以,有未便錯我的IntelliJ ...

+0

如果我這樣做:'格里芬創建應用程序內mortgageCalc',然後'CD mortgageCalc'那麼這兩個文件粘貼到模型和視圖類,它工作正常,我...謝謝 – 2013-04-11 08:43:19

+0

@tim_yates。我剛剛確認,當我從命令提示符下運行它正常工作,所以我剛剛編輯我的問題。 – Askar 2013-04-11 09:16:52

+0

確保在使用IntelliJ和Griffon時調用以下命令(從命令行):griffon integrate-with --idea 此命令生成具有完全依賴關係信息的IDEA項目文件。 – aalmiray 2013-04-11 10:47:19

回答

0

解決了! 它給出錯誤的原因,因爲我試圖運行MortgageCalView.groovy。 當我運行格里芬:mortgageCal它的工作。 :)換句話說:我必須運行該項目,而不是特定的腳本。

+0

啊是的。點擊默認的運行配置將調用項目本身的run-app命令。 – aalmiray 2013-04-11 12:07:09

相關問題