h**d 发帖数: 474 | 1 I have a property file, and would like to inject it into a spring bean as
Properties object or Map. Is there any easy way to achieve it?
Thanks. |
s******e 发帖数: 493 | 2 easiest way; use PropertyHolderConfigurer.
u can also use Spring resuorse bundle bean (forget the class name) if u want
I18N
【在 h**d 的大作中提到】 : I have a property file, and would like to inject it into a spring bean as : Properties object or Map. Is there any easy way to achieve it? : Thanks.
|
h**d 发帖数: 474 | 3 PropertyHolderConfigurer can load the property file into spring context and
use syntax ${blah} to inject single property into spring bean.
I would like to inject the whole property file into one bean without knowing
what's inside the file, for example, as Properties object.
want
【在 s******e 的大作中提到】 : easiest way; use PropertyHolderConfigurer. : u can also use Spring resuorse bundle bean (forget the class name) if u want : I18N
|
g*****g 发帖数: 34805 | 4 All you need is a getProperty interface,
at the very least you can declare such interface and implement
it by yourself.
and
knowing
【在 h**d 的大作中提到】 : PropertyHolderConfigurer can load the property file into spring context and : use syntax ${blah} to inject single property into spring bean. : I would like to inject the whole property file into one bean without knowing : what's inside the file, for example, as Properties object. : : want
|
h**d 发帖数: 474 | 5 Yep...That's what I did in my last project:)
It's easy to implement, but why can't spring provide this functionality? It'
s very common
requirement ah...
【在 g*****g 的大作中提到】 : All you need is a getProperty interface, : at the very least you can declare such interface and implement : it by yourself. : : and : knowing
|
s******e 发帖数: 493 | 6
and
knowing
If so u might want to try ResourceBundleMessageSource (option b)
【在 h**d 的大作中提到】 : PropertyHolderConfigurer can load the property file into spring context and : use syntax ${blah} to inject single property into spring bean. : I would like to inject the whole property file into one bean without knowing : what's inside the file, for example, as Properties object. : : want
|
m******t 发帖数: 2416 | 7
knowing
Or use PropertiesFactoryBean if you are running Spring 1.x.
【在 h**d 的大作中提到】 : Yep...That's what I did in my last project:) : It's easy to implement, but why can't spring provide this functionality? It' : s very common : requirement ah...
|
h**d 发帖数: 474 | 8 Thanks a lot....will give a try
【在 m******t 的大作中提到】 : : knowing : : : : Or use PropertiesFactoryBean if you are running Spring 1.x.
|