1

I have a bean (Iconstant) which has all the constant declared. I have declared the bean definition in beans.xml file. I want to load the bean property values from database. Basically, some of the values would be assigned in the beans.xml file itself and i want some to be loaded from database itself. for eg, output location of a file. I searched the internet, and all i could found is through propertyplaceholder.

So, is there any way to load the bean property value through Database ??

4

2 回答 2

1

you can use init-method or @AfterConstruct to initiate values of this bean and inject the DAO to this bean to be used to read data from database

于 2013-04-29T12:46:16.437 回答
0

Sounds like it could also be a case for injecting a value from a property file create a file

myConstants.properties

it could have this in

web.title=stack

then in cotnext definition do this

<context:property-placeholder location="classpath:myConstants.properties"/>

And in your java you can do this

@Value("${web.title}")
private String myTitle;
于 2013-04-29T12:51:03.950 回答