先上代码:
main配置:
@Ok("json:full")//整个应用默认的成功视图
@Fail("jsp:jsp.500")//失败就跳转到/jsp/5500.jsp页面
@Localization(value="msg/", defaultLocalizationKey="zh-CN")
@ChainBy(args= "mvc/nutzbook-mvc-chain.js")//设置每个请求的动作链
@SetupBy(value=MainSetup.class) //应用启动和关闭时,应该进行的处理。
@IocBy(type=ComboIocProvider.class, args={"*js", "ioc/",//读取ioc/下的js/json配置文件
"*anno", "com.gamedata",
"*tx", // // 启用内置的事务拦截器 例如: @Aop(TransAop.txREAD_COMMITTED)
"*quartz"}) //设置ioc容器加载
@Modules(scanPackage=true) //整个应用有哪些子模块
public class MainModule {
}
接口和接口的实现类:
接口:
package com.gamedata.service;
import java.util.Map;
import org.nutz.ioc.loader.annotation.IocBean;
@IocBean
public interface CompanyPlatformService {
Map<String, String> findRedisAllCompanyToPlatformMap(String gamedataAllCompanyToPlatformMap);
}
实现类:
@IocBean(name="companyPlatformService")
public class CompanyPlatformServiceImpl implements CompanyPlatformService {
@Inject
protected Dao dao;
@Aop({"redis"})
注入代码:
@IocBean(name="protocolAop")
public class ProtocolAop implements MethodInterceptor {
@Inject(value="companyPlatformService")
public CompanyPlatformService companyPlatformService;
@Inject
public GameCommonConfigService gameCommonConfigService;
@Override
public void filter(InterceptorChain chain) throws Throwable {
NutMap nutMap = (NutMap)chain.getArgs()[0];
if(StringUtils.isEmpty(nutMap)){
chain.setReturnValue(ResultUtil.faild("请求参数不能为空"));
return;
}
@Inject(value="companyPlatformService")
public CompanyPlatformService companyPlatformService;
@Inject
public GameCommonConfigService gameCommonConfigService;
这2个一直注入不进去,一直为null