简体   繁体   中英

Inject external object in a spring bean

I have a noob spring question. if i have a bean that is dependent on google's gdata api jars. How I represent this in a beans.xml file?

<bean class="com.google.foo.bar.ExternalClass" id="yourExternalBeanName" />

Then you can inject this 3rd party bean in your classes. With XML:

<property name="yourProperty" ref="yourExternalBeanName" />

or annotations:

@Inject
private ExternalClass yourProperty;

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