我有一个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
DataSource.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"
}
}
}
}
答案 0 :(得分:3)
为了清理这个主题,需要在生产块中进行调整。
更换
production {
dataSource {
dbCreate = ""
"jdbc:oracle:thin:@localhost:DB"
到
production {
dataSource {
dbCreate = ""
url = "jdbc:oracle:thin:@localhost:DB"
会奏效。