问题描述
新手学习,跟着视频做,开始用的是h2数据库,项目正常启动,后来想配置到自己本地的Oracle服务,本地Oracle没有问题,plsql可以正常连接使用。然后开始把h2的配置修改,改完后启动报错如下(另相关配置文件,见下):
org.nutz.ioc.IocException: Fail to find Method oracle.jdbc.driver.OracleDriver->close with params:
[] For object [dataSource] - type:[] FAIL to create Ioc Bean name=[dao]
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:147)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:204)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:229)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:148)
at net.wonders.nutz.MainSetup.init(MainSetup.java:21)
at org.nutz.mvc.impl.NutLoading.evalSetup(NutLoading.java:276)
at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:120)
at org.nutz.mvc.ActionHandler.<init>(ActionHandler.java:19)
at org.nutz.mvc.NutFilter._init(NutFilter.java:87)
at org.nutz.mvc.NutFilter.init(NutFilter.java:65)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:275)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:397)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3709)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4356)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:924)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:887)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1147)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: org.nutz.ioc.IocException: Fail to find Method oracle.jdbc.driver.OracleDriver->close with params:
[] For object [dataSource] - type:[]
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:211)
at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:75)
... 36 more
Caused by: java.lang.NoSuchMethodException: Fail to find Method oracle.jdbc.driver.OracleDriver->close with params:
[]
at org.nutz.lang.Mirror.findMethod(Mirror.java:1140)
at org.nutz.ioc.impl.ObjectMakerImpl.createTrigger(ObjectMakerImpl.java:169)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:52)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:204)
... 38 more
dao.js
var ioc = {
config : {
type : "org.nutz.ioc.impl.PropertiesProxy",
fields : {
paths : ["custom/database.properties"]
}
},
dataSource : {
type : "oracle.jdbc.driver.OracleDriver",
fields : {
db.url : {java : "$config.get('db.url')"},
db.dialect : {java : "$config.get('db.dialect')"},
db.username : {java : "$config.get('db.username')"},
db.password : {java : "$config.get('db.password')"},
db.testWhileIdle : {java : "$config.get('db.testWhileIdle')"},
db.validationQuery: {java : "$config.get('db.validationQuery')"},
db.maxActive : {java : "$config.get('db.maxActive')"},
db.maxWait : {java : "$config.get('db.maxWait')"},
db.minIdle : {java : "$config.get('db.minIdle')"},
db.maxIdle : {java : "$config.get('db.maxIdle')"}
},
events : {
create : "init",
depose : "close"
}
},
dao : {
type : "org.nutz.dao.impl.NutDao",
args : [{refer:"dataSource"}]
}
};
database.properties
db.url=jdbc:oracle:thin:@localhost:1521:orcl
db.dialect=org.hibernate.dialect.Oracle10gDialect
db.username=lsx
db.password=123456
db.testWhileIdle=false
db.validationQuery=SELECT COUNT(*)FROM DUAL
db.maxActive=20
db.maxWait=10000
db.minIdle=1
db.maxIdle=20
以上,望大神指教一下~新手勿喷,谢谢~~~