首页 > 其他分享 >Null return value from advice does not match primitive return type for

Null return value from advice does not match primitive return type for

时间:2022-11-07 16:12:57浏览次数:73  
标签:primitive return advice boolean does TRUE Boolean

1、org.springframework.aop.AopInvocationException:Null return value from advice does not match primitive return type for
这个错就是返回的类型不匹配

 

 

 

 

2、原因:

主要还是基本数据类型无法接受null,如果环绕返回null就报错,可以将boolean改成Boolean。

 

 

 


3、Boolean.TRUE 和 true 区别?

Boolean A(){
    return Boolean.TRUE;
}
boolean B(){
    return Boolean.TRUE
}
Boolean C(){
    return true;
}
boolean D(){
    return true;
}

 

在性能和​​内存使用效率方面,A、B效率最高,C、D会更慢,因为需要装箱和拆箱。
所以建议 Boolean 返回类型函数建议 return Boolean.TRUE;这种写法!

标签:primitive,return,advice,boolean,does,TRUE,Boolean
From: https://www.cnblogs.com/luolei0120/p/16866302.html

相关文章