gpt4 book ai didi

mysql - 此处不允许使用 Grails 和 Mysql 连接映射值

转载 作者:行者123 更新时间:2023-11-29 02:46:21 25 4
gpt4 key购买 nike

这里是我在 Mysql 数据库连接到 Grails 项目时遇到问题,我已经从终端创建了名称为 cars 的数据库,一切正常。但是当我尝试运行我的应用程序时,出现了这个错误。

| Error Error occurred running Grails CLI: mapping values are not allowed here
in 'reader', line 107, column 17:
url: "jdbc:mysql://localhost:3306/cars"
^
(Use --stacktrace to see the full trace)

这是我的 application.yml 文件

dataSource:
pooled: true
jmxExport: true
driverClassName: "com.mysql.jdbc.Driver"
username: "root"
password: "1234"


environments:
development:
dataSource:
dbCreate: update
url: "jdbc:mysql://localhost:3306/cars"
test:
dataSource:
dbCreate: update
url: "jdbc:mysql://localhost:3306/cars"
production:
dataSource:
dbCreate: none
url: "jdbc:mysql://localhost:3306/cars"
properties:
jmxEnabled: true
initialSize: 5
maxActive: 50
minIdle: 5
maxIdle: 25
maxWait: 10000
maxAge: 600000
timeBetweenEvictionRunsMillis: 5000
minEvictableIdleTimeMillis: 60000
validationQuery: SELECT 1
validationQueryTimeout: 3
validationInterval: 15000
testOnBorrow: true
testWhileIdle: true
testOnReturn: false
jdbcInterceptors: ConnectionState
defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED

这是我已经添加到依赖项中的 build.gradle 文件

runtime 'mysql:mysql-connector-java:5.1.29'

最佳答案

我认为你在第 17 行有一个额外的空间。在括号内。

        dbCreate: update
[ ]url: "jdbc:mysql://localhost:3306/cars"

您可以在此站点测试您的 yml 文件:http://yaml-online-parser.appspot.com/

像这样尝试:

dataSource:    pooled: true    jmxExport: true    driverClassName: "com.mysql.jdbc.Driver"    username: "root"    password: "1234"environments:    development:        dataSource:            dbCreate: update            url: 'jdbc:mysql://localhost:3306/cars'    test:        dataSource:            dbCreate: update            url: 'jdbc:mysql://localhost:3306/cars'    production:        dataSource:            dbCreate: none            url: "jdbc:mysql://localhost:3306/cars"            properties:                jmxEnabled: true                initialSize: 5                maxActive: 50                minIdle: 5                maxIdle: 25                maxWait: 10000                maxAge: 600000                timeBetweenEvictionRunsMillis: 5000                minEvictableIdleTimeMillis: 60000                validationQuery: SELECT 1                validationQueryTimeout: 3                validationInterval: 15000                testOnBorrow: true                testWhileIdle: true                testOnReturn: false                jdbcInterceptors: ConnectionState                defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED

关于mysql - 此处不允许使用 Grails 和 Mysql 连接映射值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41679096/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com