NutzCN Logo
问答 nutz提供的微信模块
发布于 2716天前 作者 蛋蛋的忧伤 1846 次浏览 复制 上一个帖子 下一个帖子
标签:

我按照文档继承了 BasicWxHandler类,然后加了一下代码,但是init方法没走....一直断点在那里,就是不走...


@At("/weixin") @Ok("json") public class WeixinModule { Log log = Logs.get(); /* wxHandler是被动请求的主要处理类, 里面写的1234567890就是"接口配置信息"里面提到的"token", */ protected WxHandler wxHandler = new DefaultWxHandler(); //用我的 @At // 拼起来的全路径就是 /weixin/msgin public View msgin(HttpServletRequest req) throws IOException { System.out.println("接收到消息..."); return Wxs.handle(wxHandler, req, "default"); //最后面的default,可以不写,只是个标识符. } } @IocBean(create="init", name="wxHandler") public class DefaultWxHandler extends BasicWxHandler { @Inject protected PropertiesProxy conf; // 注入配置信息加载类 public void init() { // 将读取 weixin.token/weixin.aes/weixin.appid, 他们通常会写在weixin.properties或从数据库读取. configure(conf, "weixin."); // 如果你不知道conf是啥, 完全搞不清楚状况, // 请将protected PropertiesProxy conf注释掉,configure也注释掉 // 把下面这行取消注释. // token = "1234567890"; } public WxOutMsg text(WxInMsg msg) { if ("1".equals(msg.getContent())) { return Wxs.respText("广告法说不能自称第一"); } else if ("2".equals(msg.getContent())) { return Wxs.respText("就是这么2"); } return super.text(msg); } }
11 回复
@Inject
protected WxHandler wxHandler;

他说我没找到这个bean,对啊我好像就是没有这个bean啊....

org.nutz.ioc.IocException: [weixinModule, wxHandler, class:org.nutz.ioc.impl.PropertiesProxy] # none ioc bean match class=org.nutz.ioc.impl.PropertiesProxy
	at org.nutz.ioc.impl.NutIoc.getByType(NutIoc.java:399)
	at org.nutz.ioc.val.ReferTypeValue.get(ReferTypeValue.java:66)
	at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:31)
	at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:56)
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:135)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:210)
	at org.nutz.ioc.val.ReferTypeValue.get(ReferTypeValue.java:60)
	at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:31)
	at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:56)
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:135)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:210)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:239)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:116)
	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:240)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1132)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1533)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1489)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)

大叔在拆电脑换硬盘么...

你没有配置文件?没看过nutzbook?

我response下有weixin.properties
内容为:

weixin.token=sdgergfsdfgsdg
weixin.appid=fsdgewtgetwerwerw3r

我nutzbook看到shiro了,还没看完呢...

嗯是看到的,但是没注意有PropertiesProxy这个类,因为我就写个微信demo,没涉及数据库,就只开了注解方式,没加js的ioc配置

只是添加个conf作为配置信息的集中存储

嗯.这个设计很牛,PropertiesProxy这个对象拿到了,那所有配置都拿到了,方便,牛逼,受教了.

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