在通过Annotations创建的xml配置中引用bean

Ben*_*ies 5 spring

这必须是可能的,但我无法弄清楚如何或在文档中看到它.

我需要在spring xml配置文件中引用通过注释@Service和context:component-scan创建的bean.

这是如何实现的?

干杯

Boz*_*zho 8

  1. 使用 @Service("myService")
  2. 在xml中,使用 <property name="myProperty" ref="myService"/>

  • +1,虽然#1不是绝对必要的.默认名称将设置为非大写的非限定类名; 命名策略也可以通过`BeanNameGenerator`显式指定. (4认同)