source is null for getProperty(null, "xxx")解决

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.BuilderException: Error evaluating expression 'itemCustom.title'. Cause: org.apache.ibatis.ognl.OgnlException: source is null for getProperty(null, "title")
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:75)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:371)
at com.sun.proxy.$Proxy24.selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:198)
at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:119)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:63)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)
at com.sun.proxy.$Proxy31.findItemList(Unknown Source)
at com.taotao.service.impl.ItemServiceImpl.findItemsList(ItemServiceImpl.java:159)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)

 

 

部分异常,显示为source is null for getProperty(null, "title"),其实就是itemCustom对象为空,一个空指针异常,所以获取不到title属性,之前的mapper.xml代码为


改为:

    
		
		
			
				tb_item.title LIKE '%${itemCustom.title}%'
			
		
	
	
			SELECT tb_item.* FROM tb_item 
		
			
		
    

总结:再敲每个代码时要看清楚关键性错误,避免浪费时间

你可能感兴趣的:(source is null for getProperty(null, "xxx")解决)