Spring @Value TypeMismatchException:Failed to convert value of type 'java.lang.String' to required type 'java.lang.Double'

前端 未结 3 1877
没有蜡笔的小新
没有蜡笔的小新 2020-12-14 15:45

I want to use the @Value annotation to inject a Double property such as:

@Service
public class MyService {

    @Value(\"${item.priceFactor}\")
    private D         


        
3条回答
  •  半阙折子戏
    2020-12-14 16:09

    This should solve the problem-

    @Value("#{T(Double).parseDouble('${item.priceFactor}')}")
    private Double priceFactor;
    

提交回复
热议问题