一个nutzboot项目,一个外部jar,将此jar作为依赖引入nutzboot项目。
nb项目的Mainlancher在目录com.wisedu.oa下面,代码是:
@IocBean(create="init", depose="depose")
@SetupBy(value = MainSetup.class)
@Modules
@IocBy(args={ "/ioc"})
public class MainLauncher {
@Inject
protected PropertiesProxy conf;
@Inject
protected Dao dao;
@At("/")
@Ok("->:/index.html")
public void index() {}
public void init() {
// NB自身初始化完成后会调用这个方法
dao.create(User.class, false);
if (dao.count(User.class) == 0) {
User user = new User();
user.setName("wendal");
user.setAge(18);
user.setLocation("广州");
dao.insert(user);
}
}
public void depose() {}
public static void main(String[] args) throws Exception {
new NbApp().setArgs(args).setPrintProcDoc(true).run();
}
}
jar里面的目录是com.wisedu.oa.attendce.module ,里面有一个类:
@At("/attendce")
@IocBean
public class AttendceModule {
@Inject
protected PropertiesProxy conf;
@At
@Ok("->:/index.html")
public void index() {
System.out.println("index==========="+conf.get("test"));
}
@At
@Ok("->:/test.html")
public void test() {
System.out.println("test===========");
}
}
打包nb项目,启动日志里显示
Moudle with @InjectName('attendceModule') or @IocBean('attendceModule') but no such ioc bean found!! Pls check your ioc configure!!