Bill Gorder wrote:Hi Mike,
What you have there with the mix of XML and Java config should work. What properties are not being resolved? Did you declare the PropertySourcesPlaceHolder bean as static, like in my example?
I modified the example to prove this works:
AppConfig.java
Application.java
MyBean.java
src/main/resources/app-config.xml
app.properties
This prints out the same as before followed by 'bill'
If I was not going to use the mix (no @PropertySource annotation) you can load the properties file on the PropertySourcesPlaceholder bean.
Bill,
This is additional terrific information, thanks.
However, in our application, the placeholders that are failing have a bean setup like this:
<bean id="c3po" class="com.mchange.v2.c3p0.ComboPooledDataSource">
.
.
.
</bean>
How would I get the "jdbcUrl" property from that class?
I tried before posting again to do the @ImportResource as you did, which points to the
servlet config file, but get a null for the property when I try to access it in code.
as in:
String jdbcUrl = annotateEnvironment.getProperty("jdbcUrl");
The actual property is buried inside this bean definition in the xml config file:
<bean id="c3po" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="jdbcUrl" " value="${database.url.value}"/>
</bean>
I also tried to import the bean from the XML file sort of like your updated example did, but got a casting error.
Bean myBean = context.getBean("...")
Tried with both the beanid and the class name (ComboPooledDataSource).
Does this additional information help?
Thanks again....truly appreciate your superb examples
- mike