mysql - grails 3.0.2 mysql 连接

标签 mysql grails java-8 grails-3.0

我已经在我的系统上安装了 grails 3.0.2 和 xampp 服务器。我想通过grails连接Xampp的MySql。因此,对位于 grails-app/conf 文件夹的 application.yml 文件进行了一些更改,现在看起来像

dataSource:
pooled: true
jmxExport: true
driverClassName: "com.mysql.jdbc.JDBC4MySQLConnection"//changed driver class
username: root                            //username 
password: 123456                          //password

//现在在开发环境中我更改了 dbCreat->update 和

//url->jdbc:mysql://localhost:3306/myDB //我没有对测试和生产环境进行任何更改

环境:

development:
    dataSource:
        dbCreate: update
        url: jdbc:mysql://localhost:3306/myDB;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
test:
    dataSource:
        dbCreate: update
        url: jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
production:
    dataSource:
        dbCreate: update
        url: jdbc:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE

我是 grails 新手,所以我不知道在哪里放置 mysql-connector.jar,但我已在位于 myProject/build 文件夹的 .dependencies 文件中添加了 mysql-connector.jar 的路径。

当我尝试运行我的应用程序时,它给出了很多错误,最后给出了异常

Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.JDBC4MySQLConnection at java.net.URLClassLoader$1.run(URLClassLoader.java:372) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:360) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:340) at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(Poole dConnection.java:246) ... 83 more

我无法理解错误。 如果他们是我的 mysql 连接与 grails 3.0.2 和 jdk 1.8 的步骤教程的任何步骤,请发布链接。

提前致谢。

最佳答案

Grails 3.0 使用 Gradle 构建系统来:

build related tasks such as compilation, runnings tests and producing binary distrubutions of your project

因此,您可以在 build.gradle 文件的依赖项 block 内添加依赖项:

dependencies {
    // other dependencies ...
    runtime 'mysql:mysql-connector-java:5.1.36'
}

请参阅Grails Gradle Build documentationGradle Dependency Management Basics了解更多相关信息。

关于mysql - grails 3.0.2 mysql 连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32263833/

相关文章:

mysql - 在 MySQL 中添加带小数的数字返回四舍五入的数字

mysql - Grails 域约束映射

java - Stream().map() 结果作为 Collectors.toMap() 值

eclipse - Java 8Optional.ifPresent 是我的代码错误还是 Eclipse?

mysql - 尽管我已经创建了 "Table ' 数据库,为什么它显示 ERROR 1146 'student' Student.db“不存在”?

mysql - Sequel Pro 触发器,更新第二个表中的计算字段

php - 如何在选择列表中显示类别、子类别、子子类别 - php/mysql?

grails - 数据库中的属性

grails 动态访问域对象

java-8 - Wildfly 8.2/undertow 读取超时