1. 程式人生 > >There is no getter for property named 'xxx' in 'class java.lang.String

There is no getter for property named 'xxx' in 'class java.lang.String

code app select unknown cep proxy sun myba bat

報錯信息:

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named investTime in class java.lang.String
    at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:
76) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:399) at com.sun.proxy.$Proxy30.selectOne(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:165) at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:
69) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:53) at com.sun.proxy.$Proxy36.mokuUserTotalAmount(Unknown Source)

錯誤寫法:

<if test="investDate!=null and investDate!=‘‘">
    AND invest.addtime LIKE CONCAT(%,#{investDate},%)
</if>

正確寫法:

<if
test="_parameter!=null and _parameter!=‘‘"> AND invest.addtime LIKE CONCAT(%,#{_parameter},%) </if>

總結:

如果不用if test來判斷的話,不管哪種寫法都不會報錯!建議都用_parameter來寫,多參數用Map或者封裝一個bean來做參數

There is no getter for property named 'xxx' in 'class java.lang.String