java找不到在我的xml文件中定义的Bean
我正在学习与RESTfulWebService相关的java代码,我在控制器中定义了一个Webservice,如下所示。这是别人写的 我想弄清楚一些事情
@RequestMapping(value="/updateemployeestatushistory", method=RequestMethod.GET)
public String updateemployeestatushistory
(
@RequestParam(value="employee_id", defaultValue="0") Integer employee_id,
@RequestParam(value="company_id", defaultValue="0") Integer company_id,
@RequestParam(value="new_status_id", defaultValue="0") Integer new_status_id,
@RequestParam(value="new_review_status_id", defaultValue="0") Integer new_review_status_id,
@RequestParam(value="changer_id", defaultValue="0") Integer changer_id,
@RequestParam(value="emp_status_change_comment", defaultValue="") String emp_status_change_comment,
@RequestParam(value="company_status_change_comment", defaultValue="") String company_status_change_comment
)
{
try {
// Get and validate the employee .
employeeDao rpDao = context.getBean("employeeDao", employeeDaoImpl.class);
employee employee = rpDao.findByemployeeId(employee_id);
if (employee == null) { throw new Exception("Invalid employee "); }
// Use the employee status dao to 1) update the employee and 2) add a new history record.
employeeStatusDao rpsDao = context.getBean("employeeStatusDao", employeeStatusDaoImpl.class);
rpsDao.updateStatus(context, changer_id, employee, emp_status_change_comment, new_status_id, company_status_change_comment, new_review_status_id);
result.setWebServiceStatus("Updated employee_ table, Inserted employee__HISTORY record", true);
logger.info("Status history successfully updated");
} catch(Throwable th) {
th.printStackTrace();
}
}
上面的控制器代码在我的主项目中,它引用了一个依赖项(另一个项目)。我在bean所在的位置定义了一个applicationcontext.xml
以以下方式定义并基于上述代码,我希望xml代码中有类似的内容:
<bean id="employeeStatusDao" class="abc.xyz.employee.orm.dao.impl.EmployeeStatusDaoImpl">
<property name="sessionFactory" ref="hibernate4AnnotatedSessionFactory"/>
</bean>
abc.xyz.employee.orm.dao.impl.EmployeeStatusDaoImpl
是引用依赖项中java文件的包的绝对路径。我试着去寻找
abc中的Java文件。xyz。受雇者奥姆。刀。impl目录,但找不到
我想知道我上面的控制器代码是否应该引用以下bean?因为现在,在运行
即使依赖项项目中不存在Java文件EmployeeStatusDaoImpl.java
,也会出现上述控制器代码。我可以看到logger.info
消息打印
在控制台上
另外,对我来说,java文件中的代码
^以下bean引用的{
但是发现了这样的东西:
<bean id="employeeHistoryDao" class="abc.xyz.employee.orm.dao.impl.EmployeeHistoryDaoImpl">
<property name="sessionFactory" ref="hibernate4AnnotatedSessionFactory"/>
</bean>
共 (0) 个答案