Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Is custom Spring Web Context Configuration is required for any Spring application?

    • 0
    • 1
    • 1
    • 2
    • 0
    • 0
    • 0
    • 0
    • 461
    Comment on it

    Is custom Spring Web Context Configuration (like applicationContext.xml) is required for any Spring application?

    As per knowledge, necessarily no need it, but it is a good way to separate your application layers from front-end layer:

    As we know that, in dispatcher-servlet.xml place only web-related stuff - controllers, view resolvers, converters, etc. And, in applicationContext.xml put all services and daos, and other general configurations

    Note that you'll have to declare a listener so that spring can load applicationContext.xml:

    <listener>
        <listener-class>
           org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>
    

    Then the context from applicationContext.xml will be the parent context, and the one in dispatcher-servlet.xml will be the child context. The child sees the beans in the parent, but the parent does not see those in the child.

    Also note that applicationContext.xml is a default name. You can change the name or the path where it is seeked via the contextConfigLocation (You can preffer my last Blog "Change Spring Web Context Configuration Filename").

    You do need a xml file, even if it is only to tell Spring to auto-load all the beans in your application.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: