如何将 Grails 3.0 连接到我的本地 Mysql 数据库

How to connect Grails 3.0 to my local Mysql database(如何将 Grails 3.0 连接到我的本地 Mysql 数据库)
本文介绍了如何将 Grails 3.0 连接到我的本地 Mysql 数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 Grails 很陌生,并试图将我的应用程序连接到我的本地 mysql 数据库.由于我使用的是最新版本的 Grails,我真的找不到很多文档来帮助我.是否有任何明确的文档可以指导我朝着正确的方向前进?

I'm quite new with Grails and trying to connect my application to my local mysql database. Since I'm working with the latest version of Grails, I couldn't really find a lot of documentation to help me out. Is there any clear documentation which could guide me in the right direction?

(我试过官方文档,但好像已经过时了)

(I've tried the official documentation, but it seems to be out of date)

推荐答案

Grails 3 中的数据源配置现在也通过 grails-app/conf/application.yml 文件完成.在默认项目中,它位于文件的最后一部分(以 dataSource: 开头).2015 年 8 月 1 日的 docs 仍然解释了旧的 v2,句法.但是对于开发人员来说,这应该被视为语法上的变化(从 Groovy DSL 到 YAML).例如:

Datasource configuration in Grails 3 now is done also via the grails-app/conf/application.yml file. In a default project it is located in the final section of the file (starting with dataSource:). The docs as of 2015-08-01 still explain the old, v2, syntax. But for the developer this should be seen just as a change in syntax (from a Groovy DSL to a YAML). E.g.:

dataSource:
    pooled: true
    jmxExport: true
    driverClassName: com.mysql.jdbc.Driver
    dialect: org.hibernate.dialect.MySQL5InnoDBDialect
    username: sa
    password:

environments:
    development:
        dataSource:
            dbCreate: create-drop
            url: jdbc:mysql://liveip.com/liveDb

build.gradledependencies 中添加 mysql deps 作为 runtime.例如

Add the mysql deps as runtime in the dependencies of your build.gradle. E.g.

runtime 'mysql:mysql-connector-java:5.1.36'

这篇关于如何将 Grails 3.0 连接到我的本地 Mysql 数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Hibernate reactive No Vert.x context active in aws rds(AWS RDS中的休眠反应性非Vert.x上下文处于活动状态)
Bulk insert with mysql2 and NodeJs throws 500(使用mysql2和NodeJS的大容量插入抛出500)
Flask + PyMySQL giving error no attribute #39;settimeout#39;(FlASK+PyMySQL给出错误,没有属性#39;setTimeout#39;)
auto_increment column for a group of rows?(一组行的AUTO_INCREMENT列?)
Sort by ID DESC(按ID代码排序)
SQL/MySQL: split a quantity value into multiple rows by date(SQL/MySQL:按日期将数量值拆分为多行)