var ioc = {
conf : {
type : "org.nutz.ioc.impl.PropertiesProxy",
fields : {
paths : ["custom/"]
}
},
dataSource : {
type : "com.alibaba.druid.pool.DruidDataSource",
events : {
create : "init",
depose : 'close'
},
fields : {
url : {java:"$conf.get('db.url')"},
username : {java:"$conf.get('db.username')"},
password : {java:"$conf.get('db.password')"},
testWhileIdle : true,
validationQuery : {java:"$conf.get('db.validationQuery')"},
maxActive : {java:"$conf.get('db.maxActive')"},
filters : "mergeStat",
connectionProperties : "druid.stat.slowSqlMillis=2000",
defaultAutoCommit : false // 这里
}
},
dao : {
type : "org.nutz.dao.impl.NutDaoExt",
args : [{refer:"dataSource"}],
fields : {
executor : {refer:"cacheExecutor"}
}
},
cacheExecutor : {
type : "org.nutz.plugins.cache.dao.CachedNutDaoExecutor",
fields : {
cacheProvider : {refer:"cacheProvider"},
cachedTableNames : [ "t_user_profile", "t_user", "t_role",
"t_permission", "t_role_permission", "t_topic",
"t_topic_reply", "t_oauth_user", "t_user_role" ]
}
},
/*
// 基于内存的简单LRU实现
cacheProvider : {
type : "org.nutz.plugins.cache.dao.impl.provider.MemoryDaoCacheProvider",
fields : {
cacheSize : 10000 // 缓存的对象数
},
events : {
create : "init"
}
}
*/
// 基于Ehcache的DaoCacheProvider
cacheProvider : {
type : "org.nutz.plugins.cache.dao.impl.provider.EhcacheDaoCacheProvider",
fields : {
cacheManager : {
refer : "cacheManager"
}
// 引用ehcache.js中定义的CacheManager
},
events : {
create : "init"
}
}
};
3 回复
@wendal 加入这个 好像引发了了错误!
defaultAutoCommit : false,
当程序运行的时候,数据库如果隔一段时间不去请求,,再去请求的时候出现了错误!
http://nutz.cn/yvr/t/tr73difbuii14pftqrtf9mpt5e com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException
@javanan 没设置这两个?
testWhileIdle : true,
validationQuery : {java:"$conf.get('db.validationQuery')"},
添加回复
请先登陆