spring hibernate - dao.save(object) 返回空指针异常

发布于 2024-11-13 07:43:39 字数 319 浏览 5 评论 0原文

谁能帮我解决以下问题? http:// /forum.springsource.org/showthread.php?110248-dao.save%28object%29-java.lang.NullPointerException&p=365538#post365538

非常感谢

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

月亮坠入山谷 2024-11-20 07:43:39

Spring 没有将 PatientDaoImp 注入到您的控制器中。试试这个:

public class PatientController {

  @Autowired
  private PatientDaoImp dao;

还要确保以下声明位于您的 *-servlet.xml 上下文文件(而不是主上下文文件)中:

<context:component-scan base-package="com.pems.web"/>

Spring didn't inject PatientDaoImp into your controller. Try this:

public class PatientController {

  @Autowired
  private PatientDaoImp dao;

Also make sure the following declaration is in your *-servlet.xml context file (not the main context file):

<context:component-scan base-package="com.pems.web"/>
恬淡成诗 2024-11-20 07:43:39

另外请添加:

<context:annotation-config/> 

到您的*-servlet.xml 文件中。

In addition please add:

<context:annotation-config/> 

to you *-servlet.xml file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文