2019-05-07 23:29:34,436 org.nutz.ioc.impl.PropertiesProxy.setPaths(PropertiesProxy.java:113) DEBUG - load properties from File[D:\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\alfx\WEB-INF\classes\custom\db.properties]
2019-05-07 23:29:34,437 org.nutz.ioc.impl.ScopeContext.remove(ScopeContext.java:84) DEBUG - Remove object 'wxHandler' from [app]
2019-05-07 23:29:34,438 org.nutz.ioc.impl.ScopeContext.remove(ScopeContext.java:84) DEBUG - Remove object 'weixinModule' from [app]
2019-05-07 23:29:34,438 cn.core.mvc.LogTimeProcessor.process(LogTimeProcessor.java:28) DEBUG - [ GET]URI=/alfx/weixin/msgin/ 114ms
2019-05-07 23:29:34,439 org.nutz.mvc.impl.processor.FailProcessor.process(FailProcessor.java:28) WARN - Error@/weixin/msgin/ :
org.nutz.ioc.IocException: IocBean[weixinModule] throw Exception when creating
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:149)
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.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at cn.core.mvc.LogTimeProcessor.process(LogTimeProcessor.java:23)
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:202)
at cn.core.mvc.MyNutFilter.doFilter(MyNutFilter.java:37)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at cn.core.util.XFilter.doFilter(XFilter.java:25)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:834)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1417)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: IocBean[weixinModule] fail at field=[wxHandler]
at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:40)
at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:56)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:135)
... 39 more
Caused by: org.nutz.ioc.IocException: IocBean[wxHandler] throw Exception when creating
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:149)
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:32)
... 41 more
Caused by: java.lang.RuntimeException: Ioc.$conf expect property 'weixin.token'
at org.nutz.lang.Lang.makeThrow(Lang.java:132)
at org.nutz.ioc.impl.PropertiesProxy.check(PropertiesProxy.java:191)
at org.nutz.weixin.impl.BasicWxHandler.configure(BasicWxHandler.java:49)
at cn.wx.DefaultWxHandler.init(DefaultWxHandler.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.nutz.ioc.trigger.MethodEventTrigger.trigger(MethodEventTrigger.java:18)
at org.nutz.ioc.weaver.DefaultWeaver.onCreate(DefaultWeaver.java:72)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:138)
... 44 more
package cn.wx;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.View;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Filters;
import org.nutz.weixin.util.Wxs;
@IocBean
@At("/weixin")
public class WeixinModule { // 并不要求你继承任何东西
/*
* wxHandler是被动请求的主要处理类, 里面写的1234567890就是"接口配置信息"里面提到的"token",
*/
@Inject
protected DefaultWxHandler wxHandler;
// protected WxHandler wxHandler = new BasicWxHandler("1234567890");
@At // 拼起来的全路径就是 /weixin/msgin
@Filters
public View msgin(HttpServletRequest req) throws IOException {
return Wxs.handle(wxHandler, req, "default"); // 最后面的default,可以不写,只是个标识符.
}
}
package cn.wx;
import org.nutz.ioc.impl.PropertiesProxy;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.weixin.bean.WxInMsg;
import org.nutz.weixin.bean.WxOutMsg;
import org.nutz.weixin.impl.BasicWxHandler;
import org.nutz.weixin.util.Wxs;
@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.");
// 把下面这行取消注释.
// token = "1234567890";
}
@Override
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);
}
}
weixin.properties
weixin.token=1234567890
weixin.appid=wx6a7b19b0fbd21040
weixin.aes=Z0AGiijw9vPpwUqHaS0Ev1Xqr1PkSl7BHejWhBkAUr6