Results 1 to 7 of 7

Thread: JavaConfig in Spring 3.0 RC3 issue

Hybrid View

  1. #1
    Join Date
    Dec 2009
    Posts
    3

    Default JavaConfig in Spring 3.0 RC3 issue

    Since some core features from the JavaConfig project have been added to the Spring Framework 3.0 now, I am trying to config javaconfig in a web project I am working on. Since Spring 3.0 already include some of the javaconfig, I did not include the org.springframework.config.java-1.0.0.M4.jar in the lib.

    The question is how do I config web.xml with Spring 3.0. It seemed that Spring 3.0 does not have a JavaConfigWebApplicationContext which I can init the spring application context. I think I suppose to set it up like below(this was found on the javaconfig project documentation):

    <context-param>
    <param-name>contextClass</param-name>
    <param-value>
    org.springframework.config.java.context.JavaConfig WebApplicationContext
    </param-value>
    </context-param>
    <!-- Configuration locations must consist of one or more comma- or space-delimited
    fully-qualified @Configuration classes -->
    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>com.company.config.JavaConfig</param-value>
    </context-param>
    <listener>
    <listener-class>
    org.springframework.web.context.ContextLoaderListe ner
    </listener-class>
    </listener>

    But in Spring 3.0 there is no org.springframework.config.java.context.JavaConfig WebApplicationContext. Any idea how to config javaconfig within Spring 3.0 in a web project?

    Thanks!
    Last edited by ouyanone; Dec 9th, 2009 at 10:30 AM.

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

    Default

    When posting code use [ code][/code ] tags.

    That options isn't available in spring 3.0. The annotated config is scanned by a BeanFactoryPostProcessor. So you need an xml file which either has a context:component-scan or context:annotation-config with a bean definition for your com.company.config.JavaConfig.
    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

    Default

    Spring JavaConfig was integrated into the core for Spring 3, and some of the naming conventions have been changed. You will want to use AnnotationConfigWebApplicationContext

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,632

    Default

    That is what I figured but couldn't find that class in the javadoc api. I saw the name change in SVN, strange...
    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

  5. #5

    Default

    The API is changing at a mile a minute right now. I had a similar problem in which my Maven configuration was still pointing to 3.0.0.M3, which did not include these changes. Updating it to 3.0.0.RC3 did the trick.

  6. #6
    Join Date
    Dec 2009
    Posts
    3

    Default It works great

    Thank you Jamestastic. The AnnotationConfigWebApplicationContext works great for this purpose.

Posting Permissions

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