Search code examples
javaspringconfigurationannotationsspring-webflow

How to configure Spring Webflow 2.3.1 with @Configuration?


Typically, the Spring webflow configuration is imported from application-context.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans .../>

    ....

    <import resource="config/webflow-config.xml" />

</beans>

But in spring 3.1, it is possible to perform all configuration from Java with @Configuration and get rid of application-context.xml.

I have the following for my web configuration:

@Configuration
@Import({ MyConfig1.class, MyConfig2.class })
public class WebConfig extends WebMvcConfigurerAdapter {

    ...

}

Is it possible to get rid of webflow-config.xml too using @Configuration? If yes how? If no, how to get my web configuration to include webflow-config.xml?


Solution

  • The latest Spring Webflow does not support defining flows through @Configuration, you will have to define the flows as XML and import it into a @Configuration file.

    You can use @ImportResource to import a webflow.xml file into a @Configuration File:

    @ImportResource("/WEB-INF/web/webflow.xml")