NutzCN Logo
问答 nutz和reids的怎么集成,配置文件放在哪里
发布于 2804天前 作者 qq_64f81159 2394 次浏览 复制 上一个帖子 下一个帖子
标签:

我有一个config目录,里面有一个datasource.json,里面是

var ioc = {
	conf : {
		type : "org.nutz.ioc.impl.PropertiesProxy",
		fields : {
			paths : ["config/"]
		}
	},
	dataSource:{
		type:"com.alibaba.druid.pool.DruidDataSource",
		events:{
			depose:"close"
		},
		fields:{
			url:"jdbc:mysql://127.0.0.1:3306/redis?useUnicode=true&characterEncoding=utf8",
			username:"root",
			password:"nothing",
			maxActive:20,
			testWhileIdle:true,
			validationQuery:"SELECT COUNT('x')",
			removeAbandoned:true ,
			removeAbandonedTimeout:1800,
			filters:"stat"
		}
	},
	dao : {
		type : "org.nutz.dao.impl.NutDao",
		args : [{refer:'dataSource'}]
	}
	
}

这样的 ,然后同目录有一个redis.properties文件里面是reids的配置文件
redis.host=localhost
redis.port=6379
redis.timeout=2000

redis.password=wendal.net

redis.database=0

redis.mode=cluster

然后正常的写了一个方法
jedis = jedisAgent.getResource();
User user = new User();
user.setUsername("张三");
user.setPassword("123");
String key="t:body:"+R.UU32();
jedis.set(key,Json.toJson(user));
String value = jedis.get(key);
System.err.println(value);
做放入和获得
org.nutz.ioc.IocException: [jedisPool] # For object [jedisPool] - type:[class redis.clients.util.Pool]
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:218)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:239)
at org.nutz.integration.jedis.JedisAgent.getJedisPool(JedisAgent.java:60)
at org.nutz.integration.jedis.JedisAgent.jedis(JedisAgent.java:49)
at org.nutz.integration.jedis.JedisAgent.getResource(JedisAgent.java:54)
at com.kanq.service.UserService.setUser(UserService.java:22)
at com.kanq.modules.UserModule.login(UserModule.java:40)
at com.kanq.modules.UserModule$$FASTCLASS._invoke(UserModule.java:1)
at org.nutz.lang.reflect.AbstractFastClass.invoke(AbstractFastClass.java:143)
at org.nutz.lang.reflect.FastClassFactory.invoke(FastClassFactory.java:67)
at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:27)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:33)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:198)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/pool2/PooledObjectFactory
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2570)
at java.lang.Class.getDeclaredMethods(Class.java:1855)
at org.nutz.ioc.aop.SimpleAopMaker.getInterceptorPairList(SimpleAopMaker.java:112)
at org.nutz.ioc.aop.impl.DefaultMirrorFactory.getMirror(DefaultMirrorFactory.java:64)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:36)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:210)
... 36 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.pool2.PooledObjectFactory
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
... 43 more
报错了 请问是配置文件哪里写错了??

3 回复

报的是 java.lang.ClassNotFoundException: org.apache.commons.pool2.PooledObjectFactory

缺jar了

那配置文件应该是没有错的把

先把缺的jar补全再说.

我不清楚你的ioc js放在哪里,但是 conf的paths写的是 "configs/", 所以 redis.properties的路径就是 config/redis.properties

添加回复
请先登陆
回到顶部