2012-11-15 60 views
4

我剛開始學習Grails,我試圖用grails控制檯玩弄數據庫,但我注意到運行grails console和運行grails,然後console「grails console」和「grails」之間的區別,然後是「console」

當從終端發起grails console直:

~/Desktop/Grails-lab/racetrack $ grails console 
| Compiling 1 source files..... 

console

groovy> import racetrack.* 
groovy> def z = new User(userName:"bangkuangwang",fullName:"noge noge",website:"noge.com",email:"[email protected]",bio:"hello world",password:"123123") 
groovy> z.save() 
groovy> println(z.errors) 
groovy> User.count 

grails.validation.ValidationErrors: 0 errors 

Result: 1 

當使用grails啓動,然後console

~/Desktop/Grails-lab/racetrack $ grails 
| Enter a script name to run. Use TAB for completion: 
grails> console 
| Compiling 1 source files..... 

console:爲什麼啓動Grails的安慰行爲不同的2種方法對我

groovy> import racetrack.* 
groovy> def z = new User(userName:"bangkuangwang",fullName:"noge noge",website:"noge.com",email:"[email protected]",bio:"hello world",password:"123123") 
groovy> z.save() 
groovy> println(z.errors) 
groovy> User.count 

Exception thrown 

groovy.lang.MissingMethodException: No signature of method: racetrack.User.save() is applicable for argument types:() values: [] 
Possible solutions: save(), save(boolean), save(java.util.Map), wait(), last(), any() 
at com.springsource.loaded.ri.ReflectiveInterceptor.jlrConstructorNewInstance(ReflectiveInterceptor.java:963) 
at racetrack.User.save(User.groovy) 
at racetrack.User$save.call(Unknown Source) 
at ConsoleScript0.run(ConsoleScript0:3) 
at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1231) 
at com.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1231) 

任何人都可以解釋一下嗎?

回答

0

看起來像一個錯誤。 我會建議你堅持「grails控制檯」。