网上看到一个号称很 牛逼的 数据库连接池 HikariCP ,想试一试看看效果如何,于是修改了一些 nutzwk 的配置文件,成功的跑起来了,现分享给有需要的朋友。
数据库配置 db.properties
pg.jdbcUrl=jdbc:postgresql://127.0.0.1:5432/nutzwk
pg.username=postgres
pg.password=123456
pg.connectionTestQuery=select 1
pg.maxPoolSize=20
pg.driverClassName=org.postgresql.Driver
dao.json 配置
var ioc = {
conf: {
type: "org.nutz.ioc.impl.PropertiesProxy",
fields: {
paths: ["config/custom/"]
}
},
dsconfig: {
factory: "$conf#make",
args: ["com.zaxxer.hikari.HikariConfig", "pg."],
type: "com.zaxxer.hikari.HikariConfig"
},
dataSource: {
args: [{refer: "dsconfig"}],
type: "com.zaxxer.hikari.HikariDataSource",
events: {
depose: 'close'
}
},
dao: {
type: "org.nutz.dao.impl.NutDao",
args: [{refer: "dataSource"}],
fields: {
executor: {refer: "cacheExecutor"}
}
},
cacheExecutor: {
type: "org.nutz.plugins.cache.dao.CachedNutDaoExecutor",
fields: {
cacheProvider: {refer: "cacheProvider"},
cachedTableNames: ["sys_user", "sys_role", "sys_menu"]
}
},
/*
// 基于内存的简单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.json中定义的CacheManager
},
events: {
create: "init"
}
}
};