简体   繁体   中英

Bean reference in Spring configuration file: which sintax?

Working for some time with Spring I often had to do with bean reference.

I've always used this syntax to refer to other beans in my application:

<ref bean="referenced_bean_id"/>

but sometimes, in third party applications, I see that the following sintax is also used:

<ref bean="${bean.referenced_bean_id}"/>

I haven't yet figured out what the difference is. Can you explain it?

This is what we call as "Dynamic bean referencing" , here we use property place holders so that at runtime we can decide which bean to use depending on other application parameters

for further reference you can have a look here

And a similar thread here ,

Good luck!

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