aop.AopInvocationException: Null return value from 错误很明显,但不是很理解

我的查询的语句:

@Query(value = "select u.balance from User u where u.name=:name")
    float toGetBalance(@Param("name") String name);

我的service

接口

boolean checkBalance(String userName, float totalPrice);

实现

@Transactional(readOnly = true)
    @Override
    public boolean checkBalance(String userName, float totalPrice) {

        if (userRepository.toGetBalance(userName) < totalPrice) {

            return false;

        } else {

            return true;

        }

    }

然后,在运行的时候,出错了:

org.springframework.aop.AopInvocationException: Null return value from advice does not match primitive return type for: public abstract float com.repository.UserRepository.toGetBalance(java.lang.String)

我返回的值不匹配什么地,到底哪里不匹配??

balance的类型是float啊!!
哪里错了?

阅读 7.9k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题