How to import Java-config class into XML-config so that both contexts have beans?

I have a project where I need to bootstrap @Configuration java-config classes into the XML configuration.

To do that, I'm reading that I also need to include the following bean definition (along with the bean definitions of the classes annotated with @Configuration).

<bean class="org.springframework.config.java.process.ConfigurationPostProcessor" />

But, I end up receiving the following error:

Caused by: java.lang.ClassNotFoundException: org.springframework.config.java.process.ConfigurationPostProcessor

I have to assume I'm missing a jar somewhere, but my various web searches hasn't resulted in an answer yet. Any help would be greatly appreciated. Thanks.

EDIT: Evidently, I was reading old documentation, which is no longer current. Let me back up. My project contains older XML-based configuration. The newer code is all using 'Java-config'. With that said, the contexts are apparently completely separate. I'd like to 'import' a java-config class into the XML configuration, so that both contexts have those particular beans. Does anyone know how I can do that?


This actually ended up being fairly simple. To get a Java-config bean definition into the xml-config, simply define the Java-config class as a bean within the XML-config. There are no extra jars necessary.

@Configuration
public class SomeJavaConfig {

    @bean
    ... [bean definition]
}

inside the XML-config, you define this class as a bean.

<!-- needed to pick up the annotated java-config -->
<context:annotation-config />

<!-- Importing java-config class, which are annotated with @Configuration -->
<bean name="SomeJavaConfig" class="[fully qualified path].SomeJavaConfig" />

The XML-config, which may be part of a different context, now has all the bean definitions defined within the JavaConfig class.

UPDATED - to included Alan Franzoni's comment below in the answer.


Alternatively to annotation-config you can use component-scan. Then you do not have to include the Configuration Bean in XML:

<context:component-scan base-package="[fully qualified package path]" />

See Difference between <context:annotation-config> vs <context:component-scan> for more details.