Grails 3.0.9 MySql连接器

时间:2015-11-28 02:17:08

标签: mysql grails

使用MySql和Grails 3项目时遇到问题。

我的Application.yml

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

environments:
    development:
        dataSource:
            dbCreate: create-drop
            url: jdbc:mysql://localhost:3306/mydb

也尝试了

environments:
development:
    dataSource:
        dbCreate: create-drop
        url: jdbc:mysql://localhost/mydb

我的Build.gradle

dependencies {
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-starter-actuator"
------
runtime 'mysql:mysql-connector-java:5.1.32'

然后做了一个" - 刷新依赖"

运行项目我收到此错误:

   ERROR org.apache.tomcat.jdbc.pool.ConnectionPool - Unable to create initial connections of pool.
java.sql.SQLException: com.mysql.jdbc.Driver
    at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:254) ~[tomcat-jdbc-7.0.55.jar:na]
    at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:182) ~[tomcat-jdbc-7.0.55.jar:na]
    at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:701) [tomcat-jdbc-7.0.55.jar:na]
    at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:635) [tomcat-jdbc-7.0.55.jar:na]
    at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:486) [tomcat-jdbc-7.0.55.jar:na]
    at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:144) [tomcat-jdbc-7.0.55.jar:na]
    at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:116) [tomcat-jdbc-7.0.55.jar:na]

我做错了什么?

在grails2.x上有一个lib文件夹,我可以删除下载的mysql-connector-java-5.1.32.jar文件,但是在grails 3.x上没有lib文件夹。请帮忙。:(

1 个答案:

答案 0 :(得分:0)

1)将其添加到build.gradle

dbCreate: update
driverClassName: com.mysql.jdbc.Driver"
dialect: "org.hibernate.dialect.MySQL5InnoDBDialect"
url: jdbc:mysql://localhost/mydbname?useUnicode=yes&characterEncoding=UTF-8"
username: "myusername"
password: "mypassword"

2)然后在application.yml文件中替换H2数据库,类似于这些行

{{1}}