2017-01-16 47 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