Spring之AOP奇葩报错:Null return value from advice does not match primitive return type for
2019-05-24 10:11
3415 查看
这个错是使用aop导致的 通过观察源码的到
因为环绕没有返回值为null,select方法返回类型不是void ,而是int,刚好满足条件,抛出此异常。int是无法匹配null的(除非是包装类型Integer,不过接到的一直是null)。
还是需要改环绕,加上返回值就不报错了
@Around(“execution(* com.zzq.core.test.service….(…))”)
public Object around(ProceedingJoinPoint pjp ){
System.out.println(“AOP Aronud before…”);
Object result = null;
try {
result = pjp.proceed();
System.out.println("result : "+ result);
} catch (Throwable e) {
e.printStackTrace();
}
System.out.println(“AOP Aronud after…”);
return result;
}
解决方法 我们只需要在service层改一下该方法的返回值为integer 就行了
相关文章推荐
- Spring之AOP奇葩报错:Null return value from advice does not match primitive return type for
- aop.AopInvocationException: null return value from advice does not match primitive return type for
- spring-data-jpa 报错:Parameter value element [null] did not match expected type [java.lang.String (n/a
- Spring.net Could not load type from string value
- springboot错误 java.lang.IllegalArgumentException:No converter found for return value of type
- Spring.net Could not load type from string value问题解决办法
- springboot访问方法时出错:Spring Boot Application: No converter found for return value of type
- springboot访问方法时出错:Spring Boot Application: No converter found for return value of type
- mybatis+springMVC整合出现Mapped Statements collection does not contain value for ***
- springboot访问方法时出错:Spring Boot Application: No converter found for return value of type
- Spring MVC No converter found for return value of type
- java.lang.IllegalArgumentException: XML fragments parsed from previous mappers does not contain value for
- Spring.net Could not load type from string value
- SpringMVC返回JSON提示:HttpMessageNotWritableException: No converter found for return value of type
- 《Springboot极简教程》MappingMongoConverter:Failed to convert from type [java.lang.String] to type [long] for value 'null'; ne
- Mapped Statements collection does not contain value for com.mybatis_Spring.dao.getAllUsers
- attempted to return null from a method with a primitive return type (int).
- Spring MVC No converter found for return value of type 解决方法
- 报错:attempted to return null from a method with a primitive return type (int)
- Mapped Statements (result....)collection does not contain value for...(mybatis-spring)