简体   繁体   中英

Refrence Spring Beans Generated From an Interface in XML Bean Definition

I have some code that generates a class from an interface. I need to reference that interface in a Spring XML configuration. Is there a Spring 3 annotations I can use on the interface such that I can reference the generated implementation using <constructor-arg ref="myBeanInterface"/> ?

I can reference it using <constructor-arg value="com.mysite.myBeanInterface"/> , however I want to refrence a bean name instead of an explicit class.

Details: The beans are generated by an extension of AbstractFactoryBean. I do not have access to the bean generating code.

Use the name of your factory bean. If you have something like:

<bean id="myBean class="MyBeanInterfaceFactoryBean>
    ...
</bean>

Then to inject the bean that was generated by the factory bean, just use myBean .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM