我有一个 Grails 应用程序,当我将其部署为战争时抛出异常。该异常没有任何意义,因为我的 Datasource.groovy 文件中没有配置 Grails 内存数据库。下面是异常和我的 datasource.groovy 文件。谁能告诉我为什么它一直抛出这个异常?我已经跑grails clean
了grails war
好几次了。另请注意,我确实下载了 Oracle 驱动程序,并且该应用程序在我的开发机器上运行良好。谢谢。
例外:
2013-07-22 11:41:30,265 [http-bio-8080-exec-9] ERROR StackTrace - Full Stack Trace:
java.sql.SQLException: No suitable driver
at org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1437)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
2013-07-22 11:41:30,265 [http-bio-8080-exec-9] ERROR StackTrace - Full Stack Trace:
org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'oracle.jdbc.pool.OracleDataSource' for connect URL 'jdbc:h2:mem:grailsDB;MVCC=TRUE;LOCK_TIMEOUT=10000'
at org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1452)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
Caused by: java.sql.SQLException: No suitable driver
at org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1437)
... 2 more
数据源.groovy:
dataSource {
pooled = true
driverClassName = "oracle.jdbc.pool.OracleDataSource"
dialect = "org.hibernate.dialect.Oracle10gDialect"
username = "user"
password = "password"
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:oracle:thin:@localhost:DB"
}
}
test {
dataSource {
dbCreate = ""
url = "jdbc:oracle:thin:@localhost:DB"
}
}
production {
dataSource {
dbCreate = ""
"jdbc:oracle:thin:@localhost:DB"
pooled = true
properties {
maxActive = -1
minEvictableIdleTimeMillis=1800000
timeBetweenEvictionRunsMillis=1800000
numTestsPerEvictionRun=3
testOnBorrow=true
testWhileIdle=true
testOnReturn=true
validationQuery="SELECT 1"
}
}
}
}