Brkk Brkk - 1 year ago 425
Java Question

Spring Could not Resolve placeholder

I'm fairly new to spring so excuse me if this is a dumb question. When I try to launch a program I get the following error:

java.lang.IllegalArgumentException: Could not resolve placeholder 'appclient' in string value [${appclient}]
. The error is thrown when the following code is executed:

import ca.virology.lib2.config.spring.PropertiesConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.PropertySource;

public class AppClientProperties {
private static final Logger log = LoggerFactory.getLogger(AppClientProperties.class);
//this initializer block will execute when an instance of this class is created by Spring"Loading AppClientProperties");
private int appClientPort;

private String appClientHost;

public int getAppClientPort() {
return appClientPort;

public String getAppClientHost() {
return appClientHost;

A property file called
exists in the resources folder with the information for host and port. I'm not sure where the
is defined, if it is at all. Maybe it is not even defined and that is causing the problem. Do I need to change the
to something like
or am I missing something else?

Answer Source

You are not reading the properties file correctly. The propertySource should pass the parameter as: or Change the annotation to:


However I don't know what your PropertiesConfig file contains, as you're importing that also. Ideally the @PropertySource annotation should have been kept there.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download