1. 在lib文件夹下添加 mysql-connector-java-5.0.8-bin.jar驱动
2. DataSource.groovy下添加
dataSource_mysql{
dialect=org.hibernate.dialect.MySQL5InnoDBDialect
driverClassName = 'com.mysql.jdbc.Driver'
username = 'grails'
password = 'server'
url = "jdbc:mysql://localhost:3306/crmdashboard?autoreconnect=true"
dbCreate = 'update'
pooled = true
properties {
maxActive = -1
minEvictableIdleTimeMillis=1800000
timeBetweenEvictionRunsMillis=1800000
numTestsPerEvictionRun=3
testOnBorrow=true
testWhileIdle=true
testOnReturn=true
validationQuery="SELECT 1"
}
}
3.BuildConfig.groovy 下载dependencies 下添加runtime 'mysql:mysql-connector-java:5.0.8'
4.在相应的domain class下添加方法:
static mapping={
datasource 'mysql'
}
本例中还需在mysql 登录之后修改权限:
grant all on practice.* to grails@localhost identified by 'server'