1 安装这篇文章配置的:
http://blog.csdn.net/carolzhang8406/article/details/7766281
然后直接运行一直报错:
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"
}
}
}