调试Bootstrap.groovy的最佳方法是什么? [英] What is the best way to debug Bootstrap.groovy?
问题描述
我将一些数据插入数据库,但即使我看不到任何验证错误,但仍有一些对象未插入。
例如我这样做,新的XXXXX(属性:blah)是什么错误与stacktrace或与sql的最佳方式,所以我可以找出什么是错误的? .save(flush:true)
我在启动时看不到错误(grails run-app),但我也没有看到我的数据。我确实看到了很多我的对象的数据,所以我确定它是关于我的对象,验证甚至是关联的东西,但是我需要一种简单的方法在日志/控制台中查看问题......
我确信这很容易,但是tia ...
我建议让保存()在引导期间失败时抛出异常,因为验证错误将由您的代码引起,而不是用户输入。
新的Xxxxx(property:blah)。save(failOnError:true)
漂亮罗嗦的文本块,但检查第一行,如下所示:
grails.validation.ValidationException:
验证在
save()期间发生错误:
对象中的字段错误
'mypackage.Xxxxx'字段
'myProperty ':被拒绝的值[null]
I am inserting some data into the database but some objects aren't inserting even though I can't see any validation errors. What is the best way to error with stacktrace or with sql so i can figure out what is wrong?
for example I do , new XXXXX(property: "blah").save(flush:true)
I don't see errors on startup (grails run-app) but i also don't see my data. I do see the data for many of my objects so i'm sure it's something about my objects, validation or even associations but I need a simple way to see the issue in the log/console...
i'm sure this is easy, but tia...
I recommend letting save() throw an exception if it fails during bootstrap, since a validation error will be caused by your code, not user input.
new Xxxxx(property: "blah").save(failOnError: true)
The exception will contain a pretty wordy block of text, but check the first line, which will look like:
grails.validation.ValidationException: Validation Error(s) occurred during save():
Field error in object 'mypackage.Xxxxx' on field 'myProperty': rejected value [null]
这篇关于调试Bootstrap.groovy的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!