SpringBoot:Controller层调用Service层,出现bug

2023年8月1日09:05:28

bug描述:无法直接调用service层中的方法,service层上的断点打上直接变成灰色禁用标识,且controller层中的方法无法执行到service中。

之前没遇到过,百思不得其解,maven-clean了一下,发现因为刚用了mbg重新生成了用户类,在两个地方需要重新导入,而涉及到的这个方法刚好也是需要这个user类中的ID,因此出现这个奇怪的bug。

@Controller层
SpringBoot:Controller层调用Service层,出现bug
@Service层
SpringBoot:Controller层调用Service层,出现bug
执行过程无法跳转,反而跳转到ModelMap类中的如下方法中,看提示是说属性不能为空,其实是没有为空的属性的,但是之前用过mbg重新生成了User类,所以在几个地方需要重新导一下包,没有正确识别,因此出现问题。
SpringBoot:Controller层调用Service层,出现bug
解决方法:在ProfileController中将user重新导包,即可解决。

SpringBoot:Controller层调用Service层,出现bug

  • 作者:xiaobailiying
  • 原文链接:https://blog.csdn.net/xiaobailiying/article/details/128068104
    更新时间:2023年8月1日09:05:28 ,共 345 字。