在applicationContext xml文件中添加bean时出现404
我正在尝试学习 Spring、Hibernate 和 Webflow。
为什么当我将 bean 添加到 applicationContext 时,我在运行项目时收到 404 错误。
这是我的上下文配置:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<bean id="roleService" name="roleService" class="ws.Service.RoleServiceImp" />
</beans>
现在,当我添加另一个 bean 时,它会出现 404。我不确定出了什么问题。即:
<bean id="userService" name="userService" class="ws.Service.UserServiceImp" />
我错过了什么吗?任何帮助将不胜感激。
I'm trying to learn Spring, Hibernate and Webflow.
Why is it that when I add beans to my applicationContext i get a 404 when I run the project.
Here's my context config:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<bean id="roleService" name="roleService" class="ws.Service.RoleServiceImp" />
</beans>
Now when I add another bean, it goes 404. I'm not sure what's wrong. i.e:
<bean id="userService" name="userService" class="ws.Service.UserServiceImp" />
Am I missing something? Any help will be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果 Web Spring 应用程序无法启动,例如,如果 context-xml 包含不存在的 bean,或者语法错误,那么 Spring 将不会“启动”上下文。
如果您有一个 Spring Web 应用程序,并且该应用程序没有启动,那么整个 Spring Web 请求处理内容也不会启动。当您不尝试访问通常由 spring 控制器处理的网页时,Web 服务器无法找到此处理程序,因此 Web 服务器会说:未找到 - 404。
这就是您问题的答案:“为什么是当我向 applicationContext 添加 bean 时,运行项目时会收到 404 错误。”
无论如何,我相信您对应用程序未启动的原因更感兴趣:
If an Web Spring Application can not start, for example if the context-xml contains a bean that does not exist, or a syntax error, then Spring will not "start" the context.
If you have a spring web application and the application does not start then, the whole spring web request handling stuff does not too. And when you not try to access an web page normally handled by the spring controllers the web server can not found this handler, so the web server says: not found - 404.
that is the answer to your question: "Why is it that when I add beans to my applicationContext i get a 404 when I run the project."
Anyway I believe you are more interested in why the application did not start: