ThmX
ThmX

Reputation: 149

Web App with Spring - Using properties in Service

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

Answers (2)

Bozho
Bozho

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

Related Questions