Reputation: 41
I need to inject a spring bean into an EJB 3 stateless session bean. The spring bean is declared in a jar file and initialized via a spring @Configuration class. All the examples I have run into thus far only suggest using beanRefContext.xml file (to maintain a single application context). But as all our spring beans are defined using java configuration, is there a way to combine the beanRefContext.xml file and spring's java configuration? In short, is there a way to use the AnnotationConfigApplicationContext as the bean factory from a beanRefContext?
Upvotes: 2
Views: 1370
Reputation: 5363
I faced the same issue.
Here is the solution:
<bean class="org.springframework.context.annotation.AnnotationConfigApplicationContext">
<constructor-arg>
<list>
<value type="java.lang.Class">com.company.app.SpringConfiguration</value>
</list>
</constructor-arg>
</bean>
You have to use <list>
because of how Spring handles varargs in constructor argument.
Upvotes: 2