由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - Inject property file into a spring bean?
相关主题
问个spring问题What's going on with Spring IDE's website?
这叫啥名词?找工作时Spring面试一般问题会怎么问?
spring frame work questionSpring Framework magic
JMS消息发布的问题问个Spring的问题。
spring creating objects depending on properties?spring question
请问java property file的问题请教一个spring的问题
How can I alert a spring message?guice, spring和ejb
FrameworkServlet?谁能给我推荐一个strutsspringhibernate的项目
相关话题的讨论汇总
话题: spring话题: inject话题: property话题: bean话题: file
进入Java版参与讨论
1 (共1页)
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.

1 (共1页)
进入Java版参与讨论
相关主题
谁能给我推荐一个strutsspringhibernate的项目spring creating objects depending on properties?
spring解决了什么问题? 请问java property file的问题
how to integrate java api doc with eclipHow can I alert a spring message?
System properties 怎么分的。FrameworkServlet?
问个spring问题What's going on with Spring IDE's website?
这叫啥名词?找工作时Spring面试一般问题会怎么问?
spring frame work questionSpring Framework magic
JMS消息发布的问题问个Spring的问题。
相关话题的讨论汇总
话题: spring话题: inject话题: property话题: bean话题: file