简体   繁体   中英

404 when adding beans in the applicationContext xml file

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. ie:

< bean id="userService" name="userService" class="ws.Service.UserServiceImp" />

Am I missing something? Any help will be appreciated.

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:

  • have a look in the logs, there must be a stack trace
  • if you did not find the problem, with help of the stack trace, then add it to your question (or ask a new one).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM