NutzCN Logo
问答 iocby扫描后不能识别 no match action
发布于 2836天前 作者 nidegexing 2402 次浏览 复制 上一个帖子 下一个帖子
标签:

MainModule配置如下

@Modules(scanPackage=true)
@IocBy(type=ComboIocProvider.class, args={"*js", "/ioc/",
        "*anno", "net.wendal.nutzbook","com.lewen.controllers",
        "*tx", // 事务拦截 aop
        "*async", // 异步执行aop
        "*quartz"}) // 添加了org.nutz.integration.quartz.QuartzIocLoader 这个预定义的集成配置

查看日志,com.lewen.controllers目录下的包被扫描到,但是URLmapping并没有识别到

2017-03-18 16:45:43,508 org.nutz.ioc.loader.json.JsonLoader.<init>(JsonLoader.java:56) DEBUG - Loaded 10 bean define from path=[/ioc/] --> [dao, emailAuthenticator, uploadFileContext, htmlEmail, tmpFilePool, uploadImageContext, conf, imageUpload, fileUpload, dataSource]
2017-03-18 16:45:43,527 org.nutz.resource.Scans.scan(Scans.java:274) DEBUG - Found 26 resource by src( net/wendal/nutzbook/ ) , regex( ^.+[.]class$ )
2017-03-18 16:45:43,575 org.nutz.ioc.loader.annotation.AnnotationIocLoader.addClass(AnnotationIocLoader.java:74) DEBUG - Found @IocBean : class net.wendal.nutzbook.demoModule.FormModule
2017-03-18 16:45:43,582 org.nutz.ioc.loader.annotation.AnnotationIocLoader.addClass(AnnotationIocLoader.java:74) DEBUG - Found @IocBean : class net.wendal.nutzbook.demoModule.webuploader
2017-03-18 16:45:43,593 org.nutz.ioc.loader.annotation.AnnotationIocLoader.addClass(AnnotationIocLoader.java:74) DEBUG - Found @IocBean : class net.wendal.nutzbook.module.AuthorityModule
2017-03-18 16:45:43,607 org.nutz.ioc.loader.annotation.AnnotationIocLoader.addClass(AnnotationIocLoader.java:74) DEBUG - Found @IocBean : class net.wendal.nutzbook.module.CaptchaModule
2017-03-18 16:45:43,612 org.nutz.ioc.loader.annotation.AnnotationIocLoader.addClass(AnnotationIocLoader.java:74) DEBUG - Found @IocBean : class net.wendal.nutzbook.module.UserModule
2017-03-18 16:45:43,626 org.nutz.ioc.loader.annotation.AnnotationIocLoader.addClass(AnnotationIocLoader.java:74) DEBUG - Found @IocBean : class net.wendal.nutzbook.module.UserProfileModule
2017-03-18 16:45:43,629 org.nutz.ioc.loader.annotation.AnnotationIocLoader.addClass(AnnotationIocLoader.java:74) DEBUG - Found @IocBean : class net.wendal.nutzbook.quartz.job.CleanNonActiveUserJob
2017-03-18 16:45:43,633 org.nutz.ioc.loader.annotation.AnnotationIocLoader.addClass(AnnotationIocLoader.java:74) DEBUG - Found @IocBean : class net.wendal.nutzbook.service.AuthorityServiceImpl
2017-03-18 16:45:43,634 org.nutz.ioc.loader.annotation.AnnotationIocLoader.addClass(AnnotationIocLoader.java:74) DEBUG - Found @IocBean : class net.wendal.nutzbook.service.EmailServiceImpl
2017-03-18 16:45:43,636 org.nutz.ioc.loader.annotation.AnnotationIocLoader.addClass(AnnotationIocLoader.java:74) DEBUG - Found @IocBean : class net.wendal.nutzbook.service.UserServiceImpl
2017-03-18 16:45:43,643 org.nutz.resource.Scans.scan(Scans.java:274) DEBUG - Found 2 resource by src( com/lewen/controllers/ ) , regex( ^.+[.]class$ )
2017-03-18 16:45:43,645 org.nutz.ioc.loader.annotation.AnnotationIocLoader.addClass(AnnotationIocLoader.java:74) DEBUG - Found @IocBean : class com.lewen.controllers.image.UploadController
2017-03-18 16:45:43,645 org.nutz.ioc.loader.annotation.AnnotationIocLoader.<init>(AnnotationIocLoader.java:50) INFO  - Found 11 classes in 2 base-packages!
beans = ["cleanNonActiveUserJob", "userServiceImpl", "webuploader", "uploadController", "authorityService", "userProfileModule", "captchaModule", "authorityModule", "userModule", "formModule", "emailService"]

URLmapping日志里,com.lewen.controllers包下的入口方法,并没有被扫描到

2017-03-18 16:45:43,952 org.nutz.mvc.impl.UrlMappingImpl.print(UrlMappingImpl.java:146) DEBUG -    '/user/login'               >> (UserModule.java:55).login            : Object     | @Ok(json:{locked:'password|salt',ignoreNull:true}) @Fail(http:500) | by 0 Filters | (I:UTF-8/O:UTF-8)
2017-03-18 16:45:43,953 org.nutz.mvc.impl.UrlMappingImpl.print(UrlMappingImpl.java:146) DEBUG -    '/user/login2'              >> (UserModule.java:76).login2           : Object     | @Ok(json:{locked:'password|salt',ignoreNull:true}) @Fail(http:500) | by 0 Filters | (I:UTF-8/O:UTF-8)
2017-03-18 16:45:43,955 org.nutz.mvc.impl.UrlMappingImpl.print(UrlMappingImpl.java:146) DEBUG -    '/user/update2'             >> (UserModule.java:168).update2         : Object     | @Ok(json:{locked:'password|salt',ignoreNull:true}) @Fail(http:500) | by 0 Filters | (I:UTF-8/O:UTF-8)
2017-03-18 16:45:43,956 org.nutz.mvc.impl.NutLoading.evalUrlMapping(NutLoading.java:220) INFO  - Found 36 module methods
7 回复

MainModule 放在哪里了?

package net.wendal.nutzbook;

问题出在@Modules哦,它有个pkgs,可以定义其他入口类所在的package

看了手册,是说@Modules只能自动扫描所在包(和子包)下的入口函数。也就是说虽然ioc已经加载了"net.wendal.nutzbook","com.lewen.controllers",但是入口函数只有net.wendal.nutzbook它下面的。我要com.lewen.controllers下面的也能作为入口函数,需要再写一个主函数放在这个包下,配置web.xml.有没有其他方式?

@Modules(pkgs="你的package")

多谢大侠,已搞定。ioc和入口方法的概念我有点搞混了。两者没有直接关系吧,ioc是用来注入对象的,入口方法是扫描url映射的,对吧。

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