Results 1 to 3 of 3

Thread: Mixing JavaConfig with dispatcherservlet xml

  1. #1
    Join Date
    Aug 2006
    Posts
    22

    Default Mixing JavaConfig with dispatcherservlet xml

    I have setup a bunch of beans using java config @Configuration and initialize them with the ContextLoaderListener. However, for reasons irrelevant to this question, I would like to use an xml style for the DispatcherServlet so that i have for instance a dispatch-servlet.xml in my WEB-INF folder. This doesn't seem to work. Can the two styles be mixed?
    Last edited by digid; Feb 22nd, 2012 at 09:01 AM.

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    There should be nothing preventing you from doing that. You have to either add the @Configuration classes to your xml or use component-scanning to detect them. They aren't automatically added, so you have to do some work.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Aug 2006
    Posts
    22

    Default

    Got it to work. But only after refactoring my packages and @ComponentScan annotations. For some reason if I did a scan on the base package using an includeFilter on @Service and excludeFilter on @Configuration it would still find all my other classes annotated classes(e.g. @Controller, @Repository etc. ) and would blow up. Not sure if this was really what was happening but I did get it to work by reorganizing the ComponentScan.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •