SpringBoot初次使用问题汇总

1.Invalid bound statement (not found): com.test.testdemo.mapper.UserMapper.Sel报错

解决方案:

1.查看Mapper.xml指向路径是否正确

 SpringBoot初次使用问题汇总

2.查看yml文件中的路径是否正确

SpringBoot初次使用问题汇总

2.Optional int parameter 'id' is present but cannot be translated into a null value due to being declared as a primitive type. Consider declaring it as object wrapper for the corresponding primitive type.问题

 解决方案:入参的位置添加 @PathVariable 获取url中的参数SpringBoot初次使用问题汇总

@PathVariable的作用:

是用来对指定请求的URL路径里面的变量 

 {id}在这个请求的URL里就是个变量,可以使用@PathVariable来获取

 @PathVariable和@RequestParam的区别就在于:@RequestParam用来获得静态的URL请求参数;@PathVariable用来获得动态的URL请求入参