I have in my applicationContext.xml
<context:property-placeholder location="classpath*:*.properties" />
<bean id="clientPreferencesManager" class="pl.bildpresse.bildchat2.business.ClientPreferencesManager" >
<property name="clientApiUrl" value="${clientapi.url}" />
</bean>
Is it possible to do the same by autowire ? Something like :
@Autowired
@Qualifier("${clientapi.url}")
public void setClientApiUrl(String clientApiUrl) {
this.clientApiUrl = clientApiUrl;
}
My solution is to use
and then in clientapi.properties file
This one is good too
Ok. Just got it. You need to add @Autowired Something like:
I'm using spring 3.0.0.RELEASE
Cheers
You can use
@Value
:For spring 3.0, the correct way is the one shown - using
@Value("${expression}")
For spring pre-3.0, you can try:
There were no context initialization problems here, but I'm not sure it will work. Using the resolver you can resolve properties.
It took me some time to understand why it didn't work. I always used a
#
instead of a$
. I always got the message:Just had to change it from:
to
I hope this saves somebody's time.