【发布时间】:2018-11-21 14:52:09
【问题描述】:
以下产生空错误(“A”为空),但我不知道为什么。 bean是在属性值设置之前实例化的吗?
package org.ets.readtogether.queuing;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component("Abean")
public class Test {
@Value("${send.timeout.secs}")
public Integer A;
public int B = A * 1000;
}
【问题讨论】:
-
嗯,没有对象怎么设置字段?
-
也可以在
@Value注解中使用SpEL:@Value("#{systemProperties['send.timeout.secs'] * 1000}")