This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

Wiring a bean from a database

Jun 10th, 2005, 10:56 AM

I am wiring a bean with the port values from our developer machines. I would like to retrieve the value from a database. I think a custom property editor would be the right way to accomplish this. Is there another way of accomplishing this?

You could use a PropertyPlaceholderConfigurer to externalize the properties. And there is another (spring) project that has created a few implementation (not only property files, but database access aswel), but I can`t find the link.

Comment

Here is a configuration file which loads properties from a database using Apache Commons Configuration (whose connection properties are loaded from db.properties). Since I'm using two PropertyPlaceholderConfigurer, I needed to use a different placeholderPrefix for the file based one. That way the properties in the rest of the context uses normal syntax:

Comment

I tried uisng the above setup for a properties configurer. i get the following e rror
org.springframework.beans.NotWritablePropertyExcep tion: Invalid property 'propertiesArray' of bean class [org.springframework.beans.factory.config.PropertyP laceholderConfigurer]: Bean property 'proper
tiesArray' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?