Grails会自动从域模型中生成数据库 [英] Grails auto-generate the database from the domain model

查看:114
本文介绍了Grails会自动从域模型中生成数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Netbeans中使用Grails(3.2)和MySQL创建一个简单的应用程序。
我在Grails项目中配置了MySql,并创建了一个名为 third 的数据库。在创建域类模型,控制器(脚手架)和CRUD视图后,我的项目正在运行,但每当我尝试执行任何操作时 -
错误截图



发生此错误。我无法解决这个问题,并尝试手动创建 Person 表,但发生相同的错误。 >

你的stacktrace清楚地表明你名字为 third 的db没有适当的表 person 。但你不应该手动创建这个表(如果你已经有了 - 请从你的数据库中删除所有表)



连接看起来很好,但你应查看 application.yml 中的 dbCreate 值。


dbCreate - 是否从域模型自动生成数据库
- 'create-drop','create ','update'或'validate'


https://docs.grails.org/latest/guide/conf.html



如果你正在使用简单命令 grails run-app 来启动服务器,那么您应该查看 environments:development 块中的值。



如果您需要个性化解决方案,请粘贴 application.yml 内容(不含db凭据)。


I am trying to create a simple application using Grails(3.2) and MySQL in Netbeans. I have configured MySql in Grails project and also created a database, named "third" . After creating the domain class model, the controller (scaffolded) and the views for CRUD, my project is running but whenever I am trying to do any operation - screenshot of error

this error is occuring. I am unable to solve this problem and also tried manually creating "Person" table, but same error occuring.

解决方案

Your stacktrace clearly states that your db with name third doesn't have proper table person. But you shouldn't create this table manually (if you already had - please remove all tables from your db)

Connection seems fine but you should take a look at dbCreate value in your application.yml.

dbCreate - Whether to auto-generate the database from the domain model - one of 'create-drop', 'create', 'update' or 'validate'

https://docs.grails.org/latest/guide/conf.html

If you are using just simple command grails run-app to start server, then you should check out the value in the environments: development block.

Paste your application.yml content (without db credentials) if you need a personalized solution.

这篇关于Grails会自动从域模型中生成数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆