This must be possible but I can't work out how or see it in the docs.
I need to reference a bean which has been created via an annotation @Service and context:component-scan, within a spring xml config file.
How is this achieved?
Cheers
You can wire beans using XML or annotations. In case you use annotations, you need to activate annotations and you have to add <context:annotation-config /> in applicationContext. xml. This will simplify the structure of the tag from applicationContext.
Just import the xml defining the bean with <import resource="otherXml. xml"> and you will be able to use the bean definition.
Spring @Bean Annotation is applied on a method to specify that it returns a bean to be managed by Spring context. Spring Bean annotation is usually declared in Configuration classes methods. In this case, bean methods may reference other @Bean methods in the same class by calling them directly.
@Service("myService")
<property name="myProperty" ref="myService"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With