您的位置:首页 > 大数据 > 人工智能

grails问题Cannot load JDBC driver class 'net.sourceforge.jtds.jdbc.Driver'解决方案

2016-10-19 16:43 639 查看
今天使用grails连接sqlserver数据库,数据源也配置了,jar包也放到lib文件夹里了,一输入:grails  run-app,结果傻眼了!

| Error 2016-10-19 16:02:53,562 [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.spring

framework.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 'hibernatePr

operties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hibernate.dialect]; nested exception is org.spr

ingframework.beans.factory.BeanCreationException: Error creating bean with name'dialectDetector': Invocation of init method failed; nested exception is org.spr

ingframework.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.B

eanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'session

Factory'; 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: Er

ror creating bean with name 'hibernateProperties': Cannot resolve reference to bean 'dialectDetector' while setting bean property 'properties' with key [hiberna

te.dialect]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dialectDetector': Invocation of init me

thod failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apac

he.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'net.sourceforge.jtds.jdbc.Driver'

   Line | Method

->> 303 | innerRun in java.util.concurrent.FutureTask$Sync

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

|   138 | run      in java.util.concurrent.FutureTask

|   895 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker

|   918 | run      in     ''

^   662 | run . .  in java.lang.Thread

纳尼!和例子一模一样的配置,看到这一句Cannot load JDBC driver class 'net.sourceforge.jtds.jdbc.Driver',我以为是jtds包的问题,换了两个jar包,结果不行!重写了一遍代码也是不行,后来,没办法,找度娘!姥姥,也是不靠谱;后来,参照了http://zhidao.baidu.com/link?url=2eIWhOfuzoP9W8rhcls1SxzlpeowLYggVXzNulISUsBG-T_Xt2GiyF5EZuylTL7LzNW53H0NBNRfs7-laMaF2Pd63LWvC7MWvkqTfFcBmQO;

最终执行

E:\grailswork\hellograils>grails clean

| Application cleaned.

E:\grailswork\hellograils>grails compile


E:\grailswork\hellograils>grails run-app

原来grails和java一样啊,有时候也不编译,


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  grails
相关文章推荐