Mixing xml and java config with spring

In your configuration class, you can import xml configuration via the @ImportResource annotation.

Something like this:

@Configuration
@ImportResource({"classpath:appbase-context.xml"})
public class AppConfig {
    // @Bean definitions here...
}

Remember, when you are using Spring’s Java Configuration, you need to specify an additional context-param that says the class to use for your application context:

<context-param>
    <param-name>contextClass</param-name>
    <param-value>
        org.springframework.web.context.support.AnnotationConfigWebApplicationContext
    </param-value>
</context-param>

Leave a Comment