自从添加Databaseconnection后,Grails运行应用程序错误 [英] Grails Running App errors since added Databaseconnection

查看:85
本文介绍了自从添加Databaseconnection后,Grails运行应用程序错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好亲爱的程序员,

我正在学习如何使用电子书Grails - 快速入门指南与Groovy / Grails合作,现在我正在那里工作示例项目称为TekDays。这个项目的每一步都有记录,并且描述得很好,但是我找不到我犯的一个错误。
我使用Grovvy / Grails工具套件(GGTS)作为IDE。


  • Grails版本:2.2.4

  • Groovy / Grails工具套件版本:3.4.0。 RELEASE


一切正常,但是因为我将数据库连接添加到我的MySQL数据库中,所以出现此错误:

  |加载Grails 2.2.4 
|配置类路径。
|环境设置为开发.....
|打包Grails应用程序.....
|运行Grails应用程序
| Error 2014-01-07 10:29:32,352 [localhost-startStop-1]错误context.GrailsContextLoader - 初始化应用程序时出错:创建名为'transactionManagerPostProcessor'的bean时出错:Bean初始化失败;嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为'transactionManager'的bean时出错:无法在设置bean属性'sessionFactory'时解析对bean'sessionFactory'的引用;嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为'sessionFactory'的bean时出错:在设置bean属性'hibernateProperties'时无法解析对bean'hibernateProperties'的引用;嵌套的异常是org.springframework.beans.factory.BeanCreationException:创建名为'hibernateProperties'的bean时出错:无法使用键[hibernate.dialect]设置Bean属性'属性'来引用bean'dialectDetector';嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为'dialectDetector'的bean时出错:init方法的调用失败;嵌套的异常是org.springframework.jdbc.support.MetaDataAccessException:提取DatabaseMetaData时出错;嵌套异常是org.apache.commons.dbcp.SQLNestedException:无法加载JDBC驱动程序类'com.mysql.jdbc.Driver'
消息:创建名为'transactionManagerPostProcessor'的bean时出错:Bean初始化失败;嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为'transactionManager'的bean时出错:无法在设置bean属性'sessionFactory'时解析对bean'sessionFactory'的引用;嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为'sessionFactory'的bean时出错:在设置bean属性'hibernateProperties'时无法解析对bean'hibernateProperties'的引用;嵌套的异常是org.springframework.beans.factory.BeanCreationException:创建名为'hibernateProperties'的bean时出错:无法使用键[hibernate.dialect]设置Bean属性'属性'来引用bean'dialectDetector';嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为'dialectDetector'的bean时出错:init方法的调用失败;嵌套的异常是org.springframework.jdbc.support.MetaDataAccessException:提取DatabaseMetaData时出错;嵌套异常是org.apache.commons.dbcp.SQLNestedException:无法加载JDBC驱动程序类'com.mysql.jdbc.Driver'
行|方法
- >> 334 | innerRun in java.util.concurrent.FutureTask $ Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 |在java.util.concurrent.FutureTask
|运行1145 | java.util.concurrent.ThreadPoolExecutor中的runWorker
| 615 |在java.util.concurrent.ThreadPoolExecutor $ Worker
^ 724 |中运行跑 。 。 。在java.lang.Thread中
导致BeanCreationException:创建名为'transactionManager'的bean时出错:无法在设置bean属性'sessionFactory'时解析对bean'sessionFactory'的引用。嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为'sessionFactory'的bean时出错:在设置bean属性'hibernateProperties'时无法解析对bean'hibernateProperties'的引用;嵌套的异常是org.springframework.beans.factory.BeanCreationException:创建名为'hibernateProperties'的bean时出错:无法使用键[hibernate.dialect]设置Bean属性'属性'来引用bean'dialectDetector';嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为'dialectDetector'的bean时出错:init方法的调用失败;嵌套的异常是org.springframework.jdbc.support.MetaDataAccessException:提取DatabaseMetaData时出错;嵌套异常是org.apache.commons.dbcp.SQLNestedException:无法加载JDBC驱动程序类'com.mysql.jdbc.Driver'
- >> 334 | innerRun in java.util.concurrent.FutureTask $ Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 |在java.util.concurrent.FutureTask
|运行1145 | java.util.concurrent.ThreadPoolExecutor中的runWorker
| 615 |在java.util.concurrent.ThreadPoolExecutor $ Worker
^ 724 |中运行跑 。 。 。在java.lang.Thread中引入
由BeanCreationException引发:创建名为'sessionFactory'的bean时出错:在设置bean属性'hibernateProperties'时无法解析对bean'hibernateProperties'的引用;嵌套的异常是org.springframework.beans.factory.BeanCreationException:创建名为'hibernateProperties'的bean时出错:无法使用键[hibernate.dialect]设置Bean属性'属性'来引用bean'dialectDetector';嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为'dialectDetector'的bean时出错:init方法的调用失败;嵌套的异常是org.springframework.jdbc.support.MetaDataAccessException:提取DatabaseMetaData时出错;嵌套异常是org.apache.commons.dbcp.SQLNestedException:无法加载JDBC驱动程序类'com.mysql.jdbc.Driver'
- >> 334 | innerRun in java.util.concurrent.FutureTask $ Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 |在java.util.concurrent.FutureTask
|运行1145 | java.util.concurrent.ThreadPoolExecutor中的runWorker
| 615 |在java.util.concurrent.ThreadPoolExecutor $ Worker
^ 724 |中运行跑 。 。 。在java.lang.Thread中引入
由BeanCreationException引发:创建名为'hibernateProperties'的bean时出错:无法使用键[hibernate.dialect]设置Bean属性'属性'来引用bean'dialectDetector';嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名为'dialectDetector'的bean时出错:init方法的调用失败;嵌套的异常是org.springframework.jdbc.support.MetaDataAccessException:提取DatabaseMetaData时出错;嵌套异常是org.apache.commons.dbcp.SQLNestedException:无法加载JDBC驱动程序类'com.mysql.jdbc.Driver'
- >> 334 | innerRun in java.util.concurrent.FutureTask $ Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 |在java.util.concurrent.FutureTask
|运行1145 | java.util.concurrent.ThreadPoolExecutor中的runWorker
| 615 |在java.util.concurrent.ThreadPoolExecutor $ Worker
^ 724 |中运行跑 。 。 。在java.lang.Thread中
由BeanCreationException引发:创建名为'dialectDetector'的bean时出错:init方法的调用失败;嵌套的异常是org.springframework.jdbc.support.MetaDataAccessException:提取DatabaseMetaData时出错;嵌套异常是org.apache.commons.dbcp.SQLNestedException:无法加载JDBC驱动程序类'com.mysql.jdbc.Driver'
- >> 334 | innerRun in java.util.concurrent.FutureTask $ Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 |在java.util.concurrent.FutureTask
|运行1145 | java.util.concurrent.ThreadPoolExecutor中的runWorker
| 615 |在java.util.concurrent.ThreadPoolExecutor $ Worker
^ 724 |中运行跑 。 。 。在java.lang.Thread中
导致MetaDataAccessException:提取DatabaseMetaData时出错;嵌套异常是org.apache.commons.dbcp.SQLNestedException:无法加载JDBC驱动程序类'com.mysql.jdbc.Driver'
- >> 334 | innerRun in java.util.concurrent.FutureTask $ Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 166 |在java.util.concurrent.FutureTask
|运行1145 | java.util.concurrent.ThreadPoolExecutor中的runWorker
| 615 |在java.util.concurrent.ThreadPoolExecutor $ Worker
^ 724 |中运行跑 。 。 。在java.lang.Thread中
由SQLNestedException引起:无法加载JDBC驱动程序类'com.mysql.jdbc.Driver'
- >> 1429 | org.apache.commons.dbcp.BasicDataSource中的createConnectionFactory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1371 |在''
|中创建数据源1044 | '
|中的getConnection 334 |在java.util.concurrent.FutureTask $ Sync
|中的innerRun 166 |跑 。 。 。在java.util.concurrent.FutureTask
|中1145 | java.util.concurrent.ThreadPoolExecutor中的runWorker
| 615 |跑 。 。 。在java.util.concurrent.ThreadPoolExecutor $ Worker
^ 724 |在java.lang.Thread中运行
由ClassNotFoundException引起:com.mysql.jdbc.Driver
- >> 59 | findClass in org.grails.plugins.tomcat.ParentDelegatingClassLoader $ b $ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 424 | java.lang.ClassLoader中的loadClass
| 357 | '
|中的loadClass 1420 | org.apache.commons.dbcp.BasicDataSource中的createConnectionFactory
| 1371 |在''
|中创建数据源1044 | '
|中的getConnection 334 |在java.util.concurrent.FutureTask $ Sync
|中的innerRun 166 |在java.util.concurrent.FutureTask
|运行1145 | java.util.concurrent.ThreadPoolExecutor中的runWorker
| 615 |在java.util.concurrent.ThreadPoolExecutor $ Worker
^ 724 |中运行跑 。 。 。在java.lang.Thread中

这是 DataSource.groovy

  dataSource {
pooled = code> file在这里我添加了数据库连接, true
driverClassName =com.mysql.jdbc.Driver
username =admin
password =root
}
hibernate {
cache .use_second_level_cache = true
cache.use_query_cache = false
cache.region.factory_class ='net.sf.ehcache.hibernate.EhCacheRegionFactory'
}
//环境特定设置
environments {
development {
dataSource {
dbCreate =update//'create','create-drop','update','validate',''
url =jdbc:mysql:// localhost:3306 /:tekdays
}
}
test {
dataSource {
dbCreate =update
url =jdbc:h2:mem:testDb; MVCC = TRUE; LOCK_TI MEOUT = 10000

}
生产{
dataSource {
dbCreate =update
url =jdbc:h2:prodDb; MVCC = TRUE; LOCK_TIMEOUT = 10000
pooled = true
properties {
maxActive = -1
minEvictableIdleTimeMillis = 1800000
timeBetweenEvictionRunsMillis = 1800000
numTestsPerEvictionRun = 3
testOnBorrow = true
testWhileIdle = true
testOnReturn = true
validationQuery =SELECT 1
}
}
}
}

BuildConfig.groovy

  grails.servlet.version =2.5//根据目标容器合规性(2.5或3.0)进行更改
grails.project.class .dir =target / classes
grails.project.test.class.dir =target / test-classes
grails.project.test.reports.dir = target / test-reports
grails.project.target.level = 1.6
grails.project.source.level = 1.6
//grails.project.war.file =target / $ {appName} - $ {appVersion} .war

//取消注释(并调整设置)以分离JVM以隔离类路径
//grails.project.fork = [
// run:[maxMemory:1024,minMemory:64,debug:false,maxPerm:256]
//]

grails.project.dependency.resolution = {
//继承Grails的默认依赖关系
inherits(global){
//在此处指定依赖项排除;例如,取消注释以禁用ehcache:
//排除'ehcache'
}
日志错误// Ivy解析器的日志级别,'error','warn',' info','debug'或'verbose'
checksums true //是否验证解析
上的校验和legacyResolve false //是否在插件安装时执行二级解析,不建议并且为了向后兼容

存储库{
inherits true //是否从插件继承存储库定义

grailsPlugins()
grailsHome()
grailsCentral()

mavenLocal()
mavenCentral()

//取消注释这些(或添加新的)以启用公共Maven存储库中的远程依赖项解析
// mavenRepohttp://snapshots.repository.codehaus.org
// mavenRepohttp://repository.codehaus.org
// mavenRepohttp://download.java.net/ MAV en / 2 /
// mavenRepohttp://repository.jboss.com/maven2/
}

依赖关系{
//在这里指定依赖关系在构建,编译,运行时,测试或提供的范围下

// runtime'mysql:mysql-connector-java:5.1.22'
}

plugins {
runtime':hibernate:$ grailsVersion
runtime:jquery:1.8.3
runtime:resources:1.2

//取消注释(或添加新注释)以启用其他资源功能
// runtime:zipped-resources:1.0
// runtime:cached-resources:1.0
// runtime:yui-minify-resources:0.1.5

build:tomcat:$ grailsVersion

runtime:database-migration:1.3.2

compile:cache:1.0.1'




$ b如果需要更多信息,我会尽快将其添加如果可以的话。



非常感谢您提供的每一个有用答案或评论! Lukas,你需要在你的/ lib文件夹中添加jdbc-driver并在你的BuldConfig.groovy中添加正确的依赖项,例如:

  runtime'mysql:mysql-connector-java:5.1.22'

当然取决于您使用的版本。



回到当天,我也做了这个例子我知道他们提到了这一点。



给它一下!


Hello Dear Programmers,

I'm learning to work with Groovy / Grails with the eBook "Grails - A Quick Start Guide" and now im working there with an example project called TekDays. Every step for this project is documented and well described but i cant find an fault i made.. I'm using the Grovvy / Grails Tool Suite (GGTS) as IDE.

  • Grails Version: 2.2.4
  • Groovy/Grails Tool Suite Version: 3.4.0.RELEASE

Everything worked fine but since I added the database connection to my MySQL database I'm getting this error:

| Loading Grails 2.2.4
| Configuring classpath.
| Environment set to development.....
| Packaging Grails application.....
| Running Grails application
| Error 2014-01-07 10:29:32,352 [localhost-startStop-1] ERROR    context.GrailsContextLoader  - Error initializing the application: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
Message: Error creating bean with name 'transactionManagerPostProcessor':  Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
    Line | Method
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    166 | run       in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    724 | run . . . in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'transactionManager':   Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    166 | run       in java.util.concurrent.FutureTask 
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    724 | run . . . in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'hibernateProperties' while setting bean property 'hibernateProperties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    166 | run       in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    724 | run . . . in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'hibernateProperties':  Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    166 | run       in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    724 | run . . . in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'dialectDetector':  Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    166 | run       in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    724 | run . . . in java.lang.Thread
Caused by MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    166 | run       in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    724 | run . . . in java.lang.Thread
Caused by SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
->> 1429 | createConnectionFactory in org.apache.commons.dbcp.BasicDataSource
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   1371 | createDataSource in     ''
|   1044 | getConnection in     ''
|    334 | innerRun  in java.util.concurrent.FutureTask$Sync
|    166 | run . . . in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    724 | run       in java.lang.Thread
Caused by ClassNotFoundException: com.mysql.jdbc.Driver
->>   59 | findClass in org.grails.plugins.tomcat.ParentDelegatingClassLoader
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    424 | loadClass in java.lang.ClassLoader
|    357 | loadClass in     ''
|   1420 | createConnectionFactory in org.apache.commons.dbcp.BasicDataSource
|   1371 | createDataSource in     ''
|   1044 | getConnection in     ''
|    334 | innerRun  in java.util.concurrent.FutureTask$Sync
|    166 | run       in java.util.concurrent.FutureTask
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    724 | run . . . in java.lang.Thread

This is the DataSource.groovy file where i added the database connection like it's done in the eBook:

dataSource {
    pooled = true
    driverClassName = "com.mysql.jdbc.Driver"
    username = "admin"
    password = "root"
}
hibernate {
    cache.use_second_level_cache = true
    cache.use_query_cache = false
    cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
}
// environment specific settings
environments {
    development {
        dataSource {
            dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
            url = "jdbc:mysql://localhost:3306/:tekdays"
        }
    }
    test {
         dataSource {
             dbCreate = "update"
             url = "jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
         }
    }
    production {
        dataSource {
            dbCreate = "update"
            url = "jdbc:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
            pooled = true
            properties {
               maxActive = -1
               minEvictableIdleTimeMillis=1800000
               timeBetweenEvictionRunsMillis=1800000
               numTestsPerEvictionRun=3
               testOnBorrow=true
               testWhileIdle=true
               testOnReturn=true
               validationQuery="SELECT 1"
            }
        }
    }
}

BuildConfig.groovy :

grails.servlet.version = "2.5" // Change depending on target container compliance (2.5  or 3.0)
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.target.level = 1.6
grails.project.source.level = 1.6
//grails.project.war.file = "target/${appName}-${appVersion}.war"

// uncomment (and adjust settings) to fork the JVM to isolate classpaths
//grails.project.fork = [
//   run: [maxMemory:1024, minMemory:64, debug:false, maxPerm:256]
//]

grails.project.dependency.resolution = {
    // inherit Grails' default dependencies
    inherits("global") {
        // specify dependency exclusions here; for example, uncomment this to disable  ehcache:
        // excludes 'ehcache'
    }
    log "error" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
    checksums true // Whether to verify checksums on resolve
    legacyResolve false // whether to do a secondary resolve on plugin installation,  not advised and here for backwards compatibility

    repositories {
        inherits true // Whether to inherit repository definitions from plugins

        grailsPlugins()
        grailsHome()
        grailsCentral()

        mavenLocal()
        mavenCentral()

        // uncomment these (or add new ones) to enable remote dependency resolution from public Maven repositories
        //mavenRepo "http://snapshots.repository.codehaus.org"
        //mavenRepo "http://repository.codehaus.org"
        //mavenRepo "http://download.java.net/maven/2/"
        //mavenRepo "http://repository.jboss.com/maven2/"
    }

    dependencies {
        // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.

       // runtime 'mysql:mysql-connector-java:5.1.22'
    }

    plugins {
        runtime ":hibernate:$grailsVersion"
        runtime ":jquery:1.8.3"
        runtime ":resources:1.2"

        // Uncomment these (or add new ones) to enable additional resources capabilities
        //runtime ":zipped-resources:1.0"
        //runtime ":cached-resources:1.0"
        //runtime ":yui-minify-resources:0.1.5"

        build ":tomcat:$grailsVersion"

        runtime ":database-migration:1.3.2"

        compile ':cache:1.0.1'
    }
}

If more information is needed, I will add it as fast as i can.

Thank you very much for every helpful answer or comment!

解决方案

Lukas, you need to add the jdbc-driver in you /lib-folder and add the correct dependency in your BuldConfig.groovy, for example:

runtime 'mysql:mysql-connector-java:5.1.22'

Of course depending on the version that you're using.

Back in the day I also did this example and I know that they mention this.

Give it a go!

这篇关于自从添加Databaseconnection后,Grails运行应用程序错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆