spring3 struts2框架整合错误,提示说action类注入错误

No bean named 'userService' is defined
Error creating bean with name 'action.UserAction': Injection of resource methods failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'userService' is defined
Unable to instantiate Action, action.UserAction, defined for 'user' in namespace '/'Error creating bean with name 'action.UserAction': Injection of resource methods failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'userService' is defined

2个回答

这个提示已经够明显了吧,在你的UserAction里声明的userService注入出错,找不到相应的id="userService"的bean,检查一下是不是配置文件命名写错了,如果service是注入形式的,那么检查下@Service("userService")有没有写错

 ApplicationContext context = new ClassPathXmlApplicationContext("spring/applicationContext.xml");
    使用context.getBean("?");自己获取bean,看看是不是没注册上。
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐