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

前端 未结 3 1878
没有蜡笔的小新
没有蜡笔的小新 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 15:53

    Try changing the following line

    @Value("${item.priceFactor}")
    

    to

    @Value("#{new Double('${item.priceFactor}')}")
    

提交回复
热议问题