.CodeFormat {font-family:"Courier New", Courier, mono; font-size:10pt; }
今天写了个Factory Class,用来把interface和实现的class进行组合...以便在业务逻辑中调用...类似这样:
<managers>
<manager id="DbConnectionManager">
<service>tutorial.db.IDbConnectionManager</service>
<service-impl>tutorial.db.impl.DbConnectionManagerImpl</service-impl>
</manager>
<manager id="EmployeeService">
<service>tutorial.service.iface.IEmployeeService</service>
<service-impl>tutorial.service.impl.EmployeeServiceImpl</service-impl>
</manager>
</mamagers>
在业务逻辑中,类似下面的调用:
BizFactory bizFactory = new BizFactory();
Employee employee = new Employee();
employee.setEmpNumber("9527");
//...省略...
IEmployeeService empService
= (IEmployeeService) bizFactory.create("EmployeeService");
empService.update(employee);
但是在JBuilder运行的时候,却报告EmployeeServiceImpl.class找不到...郁闷...一看才发现,JBuilder 2005在Make的时候,在${Project_Home}/classes中生成了EmployeeServiceImpl.class文件,却并没有把这个文件部署到${Project_Home}/${WebModule_Home}/WEB-INF/classes下面!
分析了半天,难道是IEmployeeService有被显示调用,而EmployeeServiceImpl没有代码显示调用,是通过Factory Class读取config xml来创建的,难道...这就是关键???
翻了半天JBuilder 2005的配置选项,终于让我发现了...见下图,去掉那个默认的选项即可!