Java 将字符串转换为整数
例如,我在application.yml中为Spring boot提供了一个属性Java 将字符串转换为整数,java,spring-boot,spring-el,Java,Spring Boot,Spring El,例如,我在application.yml中为Spring boot提供了一个属性 some: strNumber: "5" 我想以其他财产的价值为基础。比如说 some-other: intNumber: ${some.strNumber * 50} 我怎样才能做到这一点呢?不幸的是,您不能这样做:$用于读取属性而不是计算spring表达式 您实际上可以添加两个不同的属性 some: strNumber: 5 some-other: threadHold: 50 在“属性
some:
strNumber: "5"
我想以其他财产的价值为基础。比如说
some-other:
intNumber: ${some.strNumber * 50}
我怎样才能做到这一点呢?不幸的是,您不能这样做:$用于读取属性而不是计算spring表达式 您实际上可以添加两个不同的属性
some:
strNumber: 5
some-other:
threadHold: 50
在“属性上的代码”中,使用spring el表达式:
@Value("#{some.strNumber} * {some-other.threadHold}}")
private Long add;// answer will be 250
我完全不确定,但是你能试试其他的:intNumber:${some.strNumber}*50,它的计算结果是字符串
“4*50”
,那么我如何使用{}