Reputation: 149
I want to load few values from a proporties files that is in the /WEB-INF/ folder. I usually use this in my xml file when I develop a software using WebServices
<util:properties id="configProperties" location="classpath:/WEB-INF/config.properties" />
and then access to the value in Java using:
@Value("#{configProperties['clientURL']}")
private String clientURL;
public String urlClient() {
return clientURL;
}
But it doesn't work on my webapp, it's always returning the null
value.
Upvotes: 3
Views: 2934
Reputation: 149
I found the solution to my problem here: http://codingbone.wordpress.com/2010/02/28/how-to-load-properties-files-into-spring-and-expose-to-the-java-classes/
Upvotes: -1
Reputation: 597124
WEB-INF
is not on the classpath. The classpath starts from WEB-INF/classes/
. So I would advise to place the properties file there (and change the location
property accordingly). The service layer should not know that it serves a web application (which has WEB-INF
)
Upvotes: 3