NutzCN Logo
问答 nutz如何配置和使用多个数据源
发布于 3322天前 作者 lovegenii 8331 次浏览 复制 上一个帖子 下一个帖子
标签: ioc

各位大神:
我按贴子中,有人说的经验配置了多个数据源,但是没有成功。我贴出来看看
配置单:
var ioc = {
dataSource : {
type : "com.mchange.v2.c3p0.ComboPooledDataSource",
fields : {
driverClass : 'com.mysql.jdbc.Driver',
jdbcUrl : 'jdbc:mysql://127.0.0.1:3306/sales?useUnicode=true&characterEncoding=UTF8',
user : 'root',
password : '123456',
//password : '123!@#abc',

       minPoolSize : '20',
       maxPoolSize : '40',
       initialPoolSize : '20',
       maxIdleTime : '25200'

    }
},  
dataSource1 : {
    type : "com.mchange.v2.c3p0.ComboPooledDataSource",
    fields : {
       driverClass : 'com.mysql.jdbc.Driver',
       jdbcUrl : 'jdbc:mysql://127.0.0.1:3306/sales1?useUnicode=true&characterEncoding=UTF8',
       user : 'root',
       password : '123456',

       minPoolSize : '20',
       maxPoolSize : '40',
       initialPoolSize : '20',
       maxIdleTime : '25200'
    }
},  
fileSqlManager : {
    type : "org.nutz.dao.impl.FileSqlManager",
    args : ['sqls/all.sqls']
},
dao : {
    type : 'org.nutz.dao.impl.NutDao',
    args : [ {
       refer : 'dataSource'
    },{
       refer : 'fileSqlManager'
    } ]
},
dao1 : {
    type : 'org.nutz.dao.impl.NutDao',
    args : [ {
       refer : 'dataSource1'
    },{
       refer : 'fileSqlManager'
    } ]
}

};

使用方法:
@IocBean(fields = { "dao"})//第一个数据源
@InjectName("mainService")
public class MainServiceimpl extends AbstractService implements MainService {
@Inject("dao1")
public Dao dao1;//需要使用的数据源
@Override
public String test() {
String sql_sb = "select * from tb_log where id = 1 ";
Sql sql = Sqls.create(sql_sb.toString());
sql.setCallback(Sqls.callback.entities());
sql.setEntity(this.dao1.getEntity(Log.class));

    this.dao1.execute(sql);
    sql.getList(Log.class);
    return null;
}

}

报错提示为:
2015-11-06 12:54:23,480 [923219673@qtp-1836797772-0] INFO org.nutz.lang.inject.InjectByField - Fail to set value by field
org.nutz.castor.FailToCastObjectException: Fail to cast from <java.lang.String> to <org.nutz.dao.Dao> for {dao1} because:
NullPointerException:null

23 回复
@Inject("dao1")

你用的不是1.b.53吧? 用传统的完整写法

@Inject("refer:dao1")

@wendal
大神,我用的是nutz-1.b.39-jdk6.jar
用这种方式会报错
2015-11-06 13:40:42,636 [923219673@qtp-1836797772-0] ERROR org.nutz.mvc.impl.processor.FailProcessor - Catch handle error
org.nutz.ioc.IocException: For object [dao1] - type:[null]
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:191)

@lovegenii 完整报错信息

来自炫酷的 NutzCN

@wendal
完整的报错信息
2015-11-06 13:40:42,625 [923219673@qtp-1836797772-0] DEBUG org.nutz.ioc.impl.NutIoc - >> Make...'mainService'
2015-11-06 13:40:42,626 [923219673@qtp-1836797772-0] DEBUG org.nutz.ioc.impl.NutIoc - Get 'txREAD_COMMITTED'<interface org.nutz.aop.MethodInterceptor>
2015-11-06 13:40:42,635 [923219673@qtp-1836797772-0] DEBUG org.nutz.ioc.impl.ScopeContext - Save object 'mainService' to [app]
2015-11-06 13:40:42,635 [923219673@qtp-1836797772-0] DEBUG org.nutz.service.EntityService - Get TypeParams for self : nugo.business.domain.weixin.Log
2015-11-06 13:40:42,635 [923219673@qtp-1836797772-0] DEBUG org.nutz.ioc.impl.NutIoc - Get 'dao1'
2015-11-06 13:40:42,636 [923219673@qtp-1836797772-0] DEBUG org.nutz.ioc.impl.NutIoc - >> Load definition
2015-11-06 13:40:42,636 [923219673@qtp-1836797772-0] ERROR org.nutz.mvc.impl.processor.FailProcessor - Catch handle error
org.nutz.ioc.IocException: For object [dao1] - type:[null]
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:191)
at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24)
at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:23)
at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:56)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:95)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:187)
at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24)
at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:23)
at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:56)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:95)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:187)
at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:65)
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:36)
at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:66)
at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:30)
at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:60)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:399)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:928)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: org.nutz.ioc.ObjectLoadException: Object 'dao1' without define!
at org.nutz.ioc.loader.combo.ComboIocLoader.load(ComboIocLoader.java:90)
at org.nutz.ioc.loader.cached.CachedIocLoaderImpl.load(CachedIocLoaderImpl.java:47)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:169)

Caused by: org.nutz.ioc.ObjectLoadException: Object 'dao1' without define!

目测配置文件并没有更新成功哦

clean, 确保已经编译成功, 检查一下启动时的日志, 看看是不是已经部署了最新的dao.js

@wendal
大神,按你说的清理了一下,结果还是报这个错
2015-11-06 14:14:07,101 [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1] DEBUG com.mchange.v2.resourcepool.BasicResourcePool - decremented pending_acquires: 0
2015-11-06 14:14:21,752 [923219673@qtp-1836797772-0] DEBUG org.nutz.mvc.impl.UrlMappingImpl - find mapping (DEFT&[]) for path '/weixin/test'
2015-11-06 14:14:21,755 [923219673@qtp-1836797772-0] DEBUG org.nutz.ioc.impl.NutIoc - Get 'weixinController'<class nugo.business.controllers.weixin.WeixinController>
2015-11-06 14:14:21,755 [923219673@qtp-1836797772-0] DEBUG org.nutz.ioc.impl.NutIoc - >> Load definition
2015-11-06 14:14:21,755 [923219673@qtp-1836797772-0] DEBUG org.nutz.ioc.impl.NutIoc - >> Make...'weixinController'<class nugo.business.controllers.weixin.WeixinController>
2015-11-06 14:14:21,756 [923219673@qtp-1836797772-0] DEBUG org.nutz.ioc.impl.NutIoc - Get 'txREAD_COMMITTED'<interface org.nutz.aop.MethodInterceptor>
2015-11-06 14:14:21,759 [923219673@qtp-1836797772-0] DEBUG org.nutz.ioc.impl.ScopeContext - Save object 'weixinController' to [app]
2015-11-06 14:14:21,759 [923219673@qtp-1836797772-0] DEBUG org.nutz.ioc.impl.NutIoc - Get 'mainService'
2015-11-06 14:14:21,759 [923219673@qtp-1836797772-0] DEBUG org.nutz.ioc.impl.NutIoc - >> Load definition
2015-11-06 14:14:21,759 [923219673@qtp-1836797772-0] DEBUG org.nutz.ioc.impl.NutIoc - >> Make...'mainService'
2015-11-06 14:14:21,761 [923219673@qtp-1836797772-0] DEBUG org.nutz.ioc.impl.NutIoc - Get 'txREAD_COMMITTED'<interface org.nutz.aop.MethodInterceptor>
2015-11-06 14:14:21,770 [923219673@qtp-1836797772-0] DEBUG org.nutz.ioc.impl.ScopeContext - Save object 'mainService' to [app]
2015-11-06 14:14:21,771 [923219673@qtp-1836797772-0] DEBUG org.nutz.service.EntityService - Get TypeParams for self : nugo.business.domain.weixin.Log
2015-11-06 14:14:21,771 [923219673@qtp-1836797772-0] DEBUG org.nutz.ioc.impl.NutIoc - Get 'dao1'
2015-11-06 14:14:21,771 [923219673@qtp-1836797772-0] DEBUG org.nutz.ioc.impl.NutIoc - >> Load definition
2015-11-06 14:14:21,772 [923219673@qtp-1836797772-0] ERROR org.nutz.mvc.impl.processor.FailProcessor - Catch handle error
org.nutz.ioc.IocException: For object [dao1] - type:[null]
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:191)
at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24)
at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:23)
at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:56)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:95)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:187)
at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24)
at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:23)
at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:56)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:95)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:187)
at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:65)
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:36)
at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:66)
at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:30)
at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:60)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:399)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:928)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: org.nutz.ioc.ObjectLoadException: Object 'dao1' without define!
at org.nutz.ioc.loader.combo.ComboIocLoader.load(ComboIocLoader.java:90)
at org.nutz.ioc.loader.cached.CachedIocLoaderImpl.load(CachedIocLoaderImpl.java:47)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:169)
... 34 more
2015-11-06 14:14:22.479:WARN::/Elovo/weixin/test
java.lang.RuntimeException: org.apache.jasper.JasperException: java.lang.NullPointerException
at org.nutz.lang.Lang.wrapThrow(Lang.java:133)
at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:66)
at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:30)
at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:60)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:399)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:928)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

可能性有:
1. 有多个同名的配置文件,覆盖了
2. 的确没编译,导出war看看
3. 换1.b.53, 启动日志中有更多信息诊断

@wendal
大神,我按你上面说的,前二条都照做了,但是是一样的,我怀疑可就是我的版本太低了,那么如果我换成你说的版本,替换以后,会不会出现兼容问题呢?

@lovegenii 跨越那么多个版本,总会有点问题

另外你可以debug一下JsonLoader这个类,看看到底加载了哪些bean

@wendal
我试过了,是加载了的,我试试提高版本吧,不行的话,我都不知道怎么办了,谢谢大神的帮助,祈祷我换个就能好吧

@lovegenii 你确定?没有自行new NutIoc之类的代码?

如果真的加载正确,那么得继续debug一下JsonLoader的has和load方法,看看为啥传入dao1这个名字时正常返回。

来自炫酷的 NutzCN

@wendal 我把整个项目搜索了一下“new nutloc”,确实没有。
你说的debug一下,我还不怎么会用,我查一下咱们的api啥的,我现在换到版本为:1.b.49.jar,系统无任何不良反应。
同时,我查了一下,我整个项目就一个dao.js,没有任何代码了,而且,最关键的是,我的第一个dao是好用的,只有第二个是不行的

@lovegenii 高版本的话,启动的时候会打印bean的名字列表

来自炫酷的 NutzCN

另外,调换顺序,把dao1放在最前面,看看变化

来自炫酷的 NutzCN

@wendal
大神,我用尽各种办法,用了最新的版本,可是,还是出错,还有没有其它方法,让我可以使用二个数据源的?
2015-11-07 13:39:02,827 [923219673@qtp-1836797772-0] DEBUG org.nutz.ioc.impl.NutIoc - >> Make...'mainService'<>
2015-11-07 13:39:02,827 [923219673@qtp-1836797772-0] DEBUG org.nutz.ioc.impl.NutIoc - Get 'txREAD_COMMITTED'<interface org.nutz.aop.MethodInterceptor>
2015-11-07 13:39:02,832 [923219673@qtp-1836797772-0] DEBUG org.nutz.ioc.impl.ScopeContext - Save object 'mainService' to [app]
2015-11-07 13:39:02,832 [923219673@qtp-1836797772-0] DEBUG org.nutz.service.EntityService - Get TypeParams for self : nugo.business.domain.weixin.Log
2015-11-07 13:39:02,833 [923219673@qtp-1836797772-0] DEBUG org.nutz.ioc.impl.NutIoc - Get 'dao1'<>
2015-11-07 13:39:02,833 [923219673@qtp-1836797772-0] DEBUG org.nutz.ioc.impl.NutIoc - >> Load definition
2015-11-07 13:39:02,833 [923219673@qtp-1836797772-0] DEBUG org.nutz.ioc.impl.ScopeContext - Remove object 'mainService' from [app]
2015-11-07 13:39:02,833 [923219673@qtp-1836797772-0] DEBUG org.nutz.ioc.impl.ScopeContext - Remove object 'weixinController' from [app]
2015-11-07 13:39:02,834 [923219673@qtp-1836797772-0] WARN org.nutz.mvc.impl.processor.FailProcessor - Error@/weixin/test :
org.nutz.ioc.IocException: Object 'dao1' without define! For object [dao1] - type:[] FAIL to create Ioc Bean name=[mainService]
beacase [Object 'dao1' without define! For object [dao1] - type:[]] FAIL to create Ioc Bean name=[weixinController]
beacase [Object 'dao1' without define! For object [dao1] - type:[] FAIL to create Ioc Bean name=[mainService]
beacase [Object 'dao1' without define! For object [dao1] - type:[]]]
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:141)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:196)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:221)
at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:106)
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:40)
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:183)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:399)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:928)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: org.nutz.ioc.IocException: Object 'dao1' without define! For object [dao1] - type:[] FAIL to create Ioc Bean name=[mainService]
beacase [Object 'dao1' without define! For object [dao1] - type:[]]
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:141)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:196)
at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24)
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:132)
... 26 more
Caused by: org.nutz.ioc.IocException: Object 'dao1' without define! For object [dao1] - type:[]
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:203)
at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24)
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:132)
... 31 more
Caused by: org.nutz.ioc.ObjectLoadException: Object 'dao1' without define!
at org.nutz.ioc.loader.combo.ComboIocLoader.load(ComboIocLoader.java:149)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:168)
... 35 more
2015-11-07 13:39:03.483:WARN::/Elovo/weixin/test
java.lang.RuntimeException: org.apache.jasper.JasperException: java.lang.NullPointerException
at org.nutz.lang.Lang.wrapThrow(Lang.java:148)
at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:48)
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:183)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:399)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:928)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

@lovegenii 启动的时候有日志,现在加载了哪些bean

来自炫酷的 NutzCN

@wendal
@wendal 大神谢谢你的耐心哈,我的启动里,查看到这些内容,不知道能不能帮助你分析
nugo.business.services.weixin.impl.MainServiceimpl
2015-11-07 14:01:40,823 [main] INFO org.nutz.ioc.loader.annotation.AnnotationIocLoader - auto set as refer:dao1
2015-11-07 14:01:40,826 [main] DEBUG org.nutz.ioc.loader.annotation.AnnotationIocLoader - Found a Class with Ioc-Annotation : class nugo.business.services.order.link.send.FCLink

可是查对我的第一个dao,这个是好用的,它会更详细,如下:
2015-11-07 14:01:41,508 [main] DEBUG org.nutz.ioc.impl.NutIoc - Get 'dao'<>
2015-11-07 14:01:41,508 [main] DEBUG org.nutz.ioc.impl.NutIoc - >> Load definition
2015-11-07 14:01:41,508 [main] DEBUG org.nutz.ioc.loader.map.MapLoader - Loading define for name=dao
2015-11-07 14:01:41,511 [main] DEBUG org.nutz.ioc.loader.combo.ComboIocLoader - Found IocObject(dao) in IocLoader(JsonLoader@997033037)
2015-11-07 14:01:41,511 [main] DEBUG org.nutz.ioc.impl.NutIoc - >> Make...'dao'<>
2015-11-07 14:01:41,522 [main] DEBUG org.nutz.ioc.aop.impl.DefaultMirrorFactory - class org.nutz.dao.impl.NutDao without AOP
2015-11-07 14:01:41,522 [main] DEBUG org.nutz.ioc.impl.ScopeContext - Save object 'dao' to [app]
2015-11-07 14:01:41,522 [main] DEBUG org.nutz.ioc.impl.NutIoc - Get 'dataSource'<>
2015-11-07 14:01:41,522 [main] DEBUG org.nutz.ioc.impl.NutIoc - >> Load definition
2015-11-07 14:01:41,522 [main] DEBUG org.nutz.ioc.loader.map.MapLoader - Loading define for name=dataSource
2015-11-07 14:01:41,528 [main] DEBUG org.nutz.ioc.loader.combo.ComboIocLoader - Found IocObject(dataSource) in IocLoader(JsonLoader@997033037)
2015-11-07 14:01:41,528 [main] DEBUG org.nutz.ioc.impl.NutIoc - >> Make...'dataSource'<>
2015-11-07 14:01:41,537 [main] DEBUG org.nutz.ioc.aop.impl.DefaultMirrorFactory - class com.mchange.v2.c3p0.ComboPooledDataSource without AOP
2015-11-07 14:01:41,537 [main] DEBUG org.nutz.ioc.impl.ScopeContext - Save object 'dataSource' to [app]

而我找不到对应dao1的更多描述信息了,这个证明根本就没有加载吧?可是你也看到我的js了,应该是没有问题的啊

我说的是启动的信息

2015-03-30 10:49:49,603 org.nutz.mvc.impl.NutLoading.createIoc(NutLoading.java:354) DEBUG - @IocBy(type=org.nutz.mvc.ioc.provider.ComboIocProvider, args=["*js", "ioc/", "*anno", "net.wendal.nutzbook", "*tx"])
2015-03-30 10:49:49,618 org.nutz.resource.Scans.scan(Scans.java:228) DEBUG - Found 1 resource by src( ioc/ ) , regex( ^(.+[.])(js|json)$ )
2015-03-30 10:49:49,618 org.nutz.ioc.loader.json.JsonLoader.<init>(JsonLoader.java:44) DEBUG - loading ioc js config from [dao.js]
2015-03-30 10:49:49,622 org.nutz.ioc.loader.json.JsonLoader.<init>(JsonLoader.java:52) DEBUG - Loaded 2 bean define from path=[ioc/] --> [dataSource, dao]

这段

我给的链接里面已经详细说明了每行的含义

@wendal
对不起大神,我真的比较笨,还是没有搞定,后来,就决定采用其它方案了,我始终没有找到对应的内容,可能还是差在那里了,先这样吧,等有空再去想,非常感谢大神的帮助,谢谢你

找一段log而已,不至于吧

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