小编Brk*_*rkk的帖子

Spring无法解析占位符

如果这是一个愚蠢的问题,我很开心,请原谅我.当我尝试启动程序时,我收到以下错误:java.lang.IllegalArgumentException: Could not resolve placeholder 'appclient' in string value [${appclient}].执行以下代码时抛出错误:

package ca.virology.lib2.common.config.spring.properties;
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;

@Configuration
@Import({PropertiesConfig.class})
@PropertySource("${appclient}")
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
    log.info("Loading AppClientProperties");
}
@Value("${appclient.port:}")
private int appClientPort;

@Value("${appclient.host:}")
private String appClientHost;

public int getAppClientPort() {
    return appClientPort;
}

public String getAppClientHost() { …
Run Code Online (Sandbox Code Playgroud)

java spring

23
推荐指数
3
解决办法
10万
查看次数

标签 统计

java ×1

spring ×1