编译Grails项目时无法加载jdbc驱动程序类'net.sourceforge.jtds.jdbc.Driver' [英] Cannot load JDBC driver class 'net.sourceforge.jtds.jdbc.Driver' when compiling Grails project

查看:34
本文介绍了编译Grails项目时无法加载jdbc驱动程序类'net.sourceforge.jtds.jdbc.Driver'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的第一篇帖子,请温柔点!:)

我已经设置了一个Grails项目(在Grails中也是相当新的),并且正在尝试将它连接到SQL 2008数据库,我已经将jtds-1.3.0.jar添加到lib文件夹和构建路径,然后我更改了我的DataSource.groovy文件,如下所示:-

dataSource {
    pooled = true
    driverClassName = "net.sourceforge.jtds.jdbc.Driver"
    dialect = "org.hibernate.dialect.SQLServerDialect"
    }

hibernate {
    cache.use_second_level_cache = true
    cache.use_query_cache = false
    cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
}


// environment specific settings
    development {
        dataSource {
            dbCreate = "update"
        url= "jdbc:jtds:sqlserver://TestServer:1433;databaseName=TestTable"
            username = "test"
            password = "test"
        // logSql=true
        }
    }
问题是,当我试图编译时,我得到一个巨大的错误,如下所示:我遗漏了什么?我用谷歌搜索了一下,但找不到明显的解决方案.:s

| Error 2013-03-08 12:44:33,451 [localhost-startStop-1] ERROR context.GrailsContextLoader  - Error executing bootstraps: 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 'lobHandlerDetector' while setting bean property 'lobHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lobHandlerDetector': 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 'net.sourceforge.jtds.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 'lobHandlerDetector' while setting bean property 'lobHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lobHandlerDetector': 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 'net.sourceforge.jtds.jdbc.Driver'

推荐答案

我过去也遇到过类似的问题。

我已将JTDS版本更改为1.2.6,一切正常。

顺便说一句,您不需要手动添加JAR。您只需将以下内容添加到您的BuildConfig.groovy(在依赖项部分):

runtime 'net.sourceforge.jtds:jtds:1.2.6'

这篇关于编译Grails项目时无法加载jdbc驱动程序类'net.sourceforge.jtds.jdbc.Driver'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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