grails 连接Mysql

1 安装这篇文章配置的:

http://blog.csdn.net/carolzhang8406/article/details/7766281


然后直接运行一直报错:


        at groo2012-07-27 10:39:05,656 [main] ERROR context.GrailsContextLoader
 - Error executing bootstraps: Error creating bean with name 'messageSource': In
itialization of bean failed; nested exception is org.springframework.beans.facto
ry.BeanCreationException: Error creating bean with name 'transactionManager': Ca
nnot resolve reference to bean 'sessionFactory' while setting bean property 'ses
sionFactory'; nested exception is org.springframework.beans.factory.BeanCreation
Exception: Error creating bean with name 'sessionFactory': Cannot resolve refere
nce to bean 'lobHandlerDetector' while setting bean property 'lobHandler'; neste
d exception is org.springframework.beans.factory.BeanCreationException: Error cr
eating bean with name 'lobHandlerDetector': Invocation of init method failed; ne
sted exception is org.springframework.jdbc.support.MetaDataAccessException: Erro
r while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp
.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
org.springframework.beans.factory.BeanCreationException: Error creating bean wit
h name 'messageSource': Initialization of bean failed; nested exception is org.s
pringframework.beans.factory.BeanCreationException: Error creating bean with nam
e '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 'sessionFacto
ry': Cannot resolve reference to bean 'lobHandlerDetector' while setting bean pr
operty 'lobHandler'; nested exception is org.springframework.beans.factory.BeanC
reationException: Error creating bean with name 'lobHandlerDetector': Invocation

 of init method failed; nested exception is org.springframework.jdbc.support.Met


can not load com.mysql.jdbc.Driver

.............................

..........................

然后google ,baidu  试了很多方法,都不对,人都快崩溃了,无意中看到下面这篇文章,找到问题所在,原来我所参考的文章并不对,下载这个zip包之后需要解压,把mysql-connector-java-5.1.21-bin.jar 这个拷贝到lib下面。



1.先下载MySql的驱动, http://www.mysql.com/products/connector/j/

2.将MySql的Jar包放到项目的lib文件夹下

http://www.grsage.com/new/GrailsMysql.html



然后重新运行,搞定 。

dataSource {
    pooled = true
    driverClassName = "com.mysql.jdbc.Driver"
    username = "root"
    password = "root"
    dialect = org.hibernate.dialect.MySQL5InnoDBDialect
}
hibernate {
    cache.use_second_level_cache = true
    cache.use_query_cache = true
    cache.provider_class = 'net.sf.ehcache.hibernate.EhCacheProvider'
}
// environment specific settings
environments {
    development {
        dataSource {
            dbCreate = "create" // one of 'create', 'create-drop','update'
            url = "jdbc:mysql://127.0.0.1/grails?useUnicode=true&characterEncoding=UTF-8"  //你所创建的DB的名称,至于前面写localhost 和127那种都行,如果不在一个机器上,替换为对应的机器名。
        }
        hibernate {
            show_sql = true
        }
    }
    test {
        dataSource {
            dbCreate = "create-drop" // one of 'create', 'create-drop','update'
             url = "jdbc:mysql://127.0.0.1/grails?useUnicode=true&characterEncoding=UTF-8"


        }
    }
    production {
        dataSource {
            dbCreate = "update"
             url = "jdbc:mysql://127.0.0.1/grails?useUnicode=true&characterEncoding=UTF-8"


        }
    }
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

惹不起的程咬金

来都来了,不赏点银子么

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值