2017-01-16 51 views
0

这里是我有问题与谷歌项目的MySQL Db连接,我创建了这个数据库与终端名称汽车一切都是okey。但是,当我尝试运行我的应用程序时,出现此错误。Grails&Mysql连接映射值不允许在这里

| 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

我认为你有一个额外的空间在第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 

+0

不工作,是同 –

+0

我同样的结果进行了测试:只是删除“测试”块中“url”前面的空格。或者修复“测试”模块以进一步调试。 – gregorr