1. 程式人生 > >錯誤TypeMismatchException: Failed to convert property value of type [java.lang解決與原因?

錯誤TypeMismatchException: Failed to convert property value of type [java.lang解決與原因?

      當你在開發時遇到這樣的問題時,說明你的配置檔案並沒有被spring容器載入到,所以導致這樣的錯誤,如圖:這時先檢查一下你的配置檔案是否被載入

 

Caused by: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [int] for property 'maxIdle'; nested exception is java.lang.NumberFormatException: For input string: "${redis.maxIdle}"

    at org.springframework.beans.AbstractNestablePropertyAccessor.convertIfNecessary(AbstractNestablePropertyAccessor.java:596)     at org.springframework.beans.AbstractNestablePropertyAccessor.convertForProperty(AbstractNestablePropertyAccessor.java:603)     at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:204)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1527)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1486)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1226)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)     ... 20 more Caused by: java.lang.NumberFormatException: For input string: "${redis.maxIdle}"     at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)     at java.lang.Integer.parseInt(Integer.java:569)     at java.lang.Integer.valueOf(Integer.java:766)     at org.springframework.util.NumberUtils.parseNumber(NumberUtils.java:194)     at org.springframework.beans.propertyeditors.CustomNumberEditor.setAsText(CustomNumberEditor.java:113)     at org.springframework.beans.TypeConverterDelegate.doConvertTextValue(TypeConverterDelegate.java:464)     at org.springframework.beans.TypeConverterDelegate.doConvertValue(TypeConverterDelegate.java:437)     at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:195)     at org.springframework.beans.AbstractNestablePropertyAccessor.convertIfNecessary(AbstractNestablePropertyAccessor.java:576)