这里是我有问题与Mysql Db连接Grails项目,我已经创建这个数据库与名称汽车从终端一切都是okey。但是,当我尝试运行我的应用程序时,我收到此错误。
| 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'
答案 0 :(得分:1)
我认为你在第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