调试Bootstrap.groovy的最佳方法是什么?

编程入门 行业动态 更新时间:2024-10-11 23:26:11
本文介绍了调试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的最佳方法是什么?

本文发布于:2023-11-07 10:27:53,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:方法   Bootstrap   groovy

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!