NutzCN Logo
问答 引用自定义dao 出错
发布于 2337天前 作者 yy321973351 1784 次浏览 复制 上一个帖子 下一个帖子
标签:
org.nutz.ioc.IocException: IocBean[countController] 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 com.wangzc.mvc.processor.LogTimeProcessor.process(LogTimeProcessor.java:25)
	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 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 org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
	at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
	at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
	at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
	at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
	at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
	at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	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:198)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1468)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	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)
Caused by: java.lang.RuntimeException: IocBean[countController] fail at field=[sqldao]
	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)
	... 49 more
Caused by: org.nutz.ioc.IocException: IocBean[sqldao -> class:java.lang.String] none ioc bean match class=java.lang.String
	at org.nutz.ioc.impl.NutIoc.getByType(NutIoc.java:399)
	at org.nutz.ioc.val.ReferTypeValue.get(ReferTypeValue.java:66)
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:75)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:210)
	at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24)
	at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:32)
	... 51 more
15:46:08.555 [DefaultQuartzScheduler_QuartzSchedulerThread] DEBUG o.quartz.core.QuartzSchedulerThread - batch acquisition of 0 triggers

package com.yx.quick.admin.sql;

import org.nutz.dao.Dao;
import org.nutz.dao.impl.FileSqlManager;
import org.nutz.dao.impl.NutDao;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;

import javax.sql.DataSource;

/**
 * Created by Administrator on 2018/6/22.
 */
@IocBean
public class MyDao {
    @IocBean
    public Dao  sqldao(@Inject DataSource dataSource,@Inject("java:$conf.get('sqlpath')") String path){
       return new NutDao(dataSource,new FileSqlManager(path));

    }
}

IocBean
@At("/count")
@Ok("json")
public class CountController extends BaseController {
    @Inject("refer:sqldao")
    protected Dao sqldao;

    @Inject("java:$conf.get('default_time_interval')")

配置文件

sqlpath=/sql

sql文件夹在 resources 下面

16 回复
var ioc = {
    dataSource: {
        type: "com.alibaba.druid.pool.DruidDataSource",
        events: {
            create: "init",
            depose: 'close'
        },
        fields: {
            url: {
                java: "$conf.get('db.url')"
            },
            username: {
                java: "$conf.get('db.username')"
            },
            password: {
                java: "$conf.get('db.password')"
            },
            testWhileIdle: true,
            validationQuery: {
                java: "$conf.get('db.validationQuery')"
            },
            maxActive: {
                java: "$conf.get('db.maxActive')"
            },
            filters: "mergeStat",
            connectionProperties: "druid.stat.slowSqlMillis=2000",
            maxWait: 5000//毫秒数,5秒内拿不到新连接就抛异常
        }
    },
    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_menu"]
        }
    },
    // 基于Ehcache的DaoCacheProvider
    cacheProvider: {
        type: "org.nutz.plugins.cache.dao.impl.provider.EhcacheDaoCacheProvider",
        fields: {
            cacheManager: {refer: "cacheManager"} // 引用ehcache.js中定义的CacheManager
        },
        events: {
            create: "init"
        }
    }
};

这样试试

@Inject
protected Dao sqldao;

启动日志里面有没有扫描到sqldao

改成 @IocBean(name="sqldao") 试试

是不是在js里面也声明了sqldao?

beans = ["uploadController", "quotaService", "rongHangApi", "routeService", "redisPartnerService", "sysLoginController", "holidayService", "uloApi", "daoheApi", "sysPermissionController", "ordersController", "zxApi", "daohe2Api", "partnerWftController", "indexController", "sysUserRoleController", "daoheScanApi2", "sysMenuService", "sysRolePermissionService", "kuaiLeApi", "countController", "riskService", "ordersSubjectService", "redisIpaddressService", "sqldao", "sysLogController", "shenYangPingAnApi", "cacheService", "sandScanApi", "payforController", "payforService", "partnerQuotaController", "redisHolidayService", "quartzJobSettleForOrders14", "ipAddressService", "legalHolidaysController", "sysRolePermissionController", "wFTScanApi", "quartzJobSettleForCompany", "ordersSettleController", "homeController", "channelConfigController", "sysUserService", "partnerController", "quartzJobSettlePartnerBalance", "sysUserDataService", "sysMsgController", "orderService", "sysMsgService", "channelConfigInfoController", "sandApi", "sysUserRolePermissionService", "partnerCardController", "redisChannelConfigService", "agentIncomeController", "adminService", "sysLogService", "daoheScanApi", "sysMenuController", "ordersRefundController", "partnerWithdrawController", "quartzJobSettleForOrders", "ordersSubjectController", "partnerBalanceController", "partnerBillController", "partnerService", "sysRoleController", "ulo2Api", "ipaddressController", "partnerPaytypeController", "sysUserController", "sysUserDataController", "myDao"]

org.nutz.ioc.IocException: IocBean[countController] 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 com.wangzc.mvc.processor.LogTimeProcessor.process(LogTimeProcessor.java:25)
	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 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 org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
	at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
	at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
	at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
	at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
	at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
	at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	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:198)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1468)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	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)
Caused by: java.lang.RuntimeException: IocBean[countController] fail at field=[sqldao]
	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)
	... 49 more
Caused by: org.nutz.ioc.IocException: IocBean[sqldao -> class:java.lang.String] none ioc bean match class=java.lang.String
	at org.nutz.ioc.impl.NutIoc.getByType(NutIoc.java:399)
	at org.nutz.ioc.val.ReferTypeValue.get(ReferTypeValue.java:66)
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:75)
	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)
	... 51 more

nutz版本多少?

太低了,不支持方法上写@IocBean

org.nutz.ioc.IocException: IocBean[countController] 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 com.wangzc.mvc.processor.LogTimeProcessor.process(LogTimeProcessor.java:25)
	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 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 org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
	at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
	at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
	at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
	at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
	at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
	at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	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:198)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1468)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	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)
Caused by: java.lang.RuntimeException: IocBean[countController] fail at field=[sqldao]
	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)
	... 49 more
Caused by: org.nutz.ioc.IocException: IocBean[sqldao -> fileSqlManager -> class:java.lang.String] none ioc bean match class=java.lang.String
	at org.nutz.ioc.impl.NutIoc.getByType(NutIoc.java:399)
	at org.nutz.ioc.val.ReferTypeValue.get(ReferTypeValue.java:66)
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:75)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:210)
	at org.nutz.ioc.val.ReferTypeValue.get(ReferTypeValue.java:60)
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:75)
	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)
	... 51 more
16:40:06.423 [DefaultQuartzScheduler_QuartzSchedulerThread] DEBUG o.quartz.core.QuartzSchedulerThread - batch acquisition of 0 triggers

package com.yx.quick.admin.sql;

import org.nutz.dao.Dao;
import org.nutz.dao.impl.FileSqlManager;
import org.nutz.dao.impl.NutDao;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Mirror;

import javax.sql.DataSource;

/**
 * Created by Administrator on 2018/6/22.
 */
@IocBean
public class MyDao {

    @IocBean
    public FileSqlManager fileSqlManager(   @Inject("java:$conf.get('sqlpath')") String path) {
        return Mirror.me(FileSqlManager.class).born(path);
    }

    @IocBean(name="sqldao")
    public Dao  sqldao(@Inject DataSource dataSource,  @Inject FileSqlManager fileSqlManager){
        NutDao sqldao = Mirror.me(NutDao.class).born(dataSource);
        sqldao.setSqlManager(fileSqlManager);
        return sqldao;

    }



}

order.sqls 文件下
/* select.orders */
select
FROM_UNIXTIME((floor(UNIX_TIMESTAMP(create_time) / @time))*@time)  as startdate
,date_add(FROM_UNIXTIME((floor(UNIX_TIMESTAMP(create_time) / @time))*@time),INTERVAL @time second ) as endDate
,cast((sum(if(order_status='01',1,0)) /count(1))*100 as decimal(9,2))   as tongji
from orders    $wherename      GROUP BY  FROM_UNIXTIME((floor(UNIX_TIMESTAMP(create_time) / @time))*@time)

那样如何生成自定义dao

先升级nutz到最新版

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