1、SpringBoot 项目,在controller层返回页面的时候 始终返回的是字符串
问题就在于加上了@ResponseBody这个注解,或者@RestController
作用:该注解用于将Controller的方法返回的对象,通过适当的HttpMessageConverter转换为指定格式后,写入到Response对象的body数据区。
使用时机:返回的数据不是html标签的页面,而是其他某种格式的数据时(如json、xml等)使用;如果返回到页面是map或者json或者list等,加上@ResponseBody准没错,如果你想跳转到一个页面,那么千万别加@ResponseBody,因为这个注解会将你返回的东西放到response的body数据中去
https://www.cnblogs.com/estelleup/p/8854612.html
2、项目无法识别mapper,报错:
consider defining a bean of type '*.*.**Repository' in your configuration.
①原因在于没有扫描到mapper文件,解决方法为在启动类加@EntityScan("com.wl.entity")和@MapperScan("com.wl.repository")两个注解,前一个是扫描entity实体类,后面是扫描repository即mapper类,这样在其他地方使用mapper的时候能够自动注入。
https://blog.csdn.net/qq_26854457/article/details/80827615
②在application.properties中加入mybatis.mapper-locations=mapper/*.xml
https://blog.csdn.net/qq_27130997/article/details/81077789
3、运行springboot项目报错
①Field Service in com.controller.Controller required a bean of type
原因在于serviceimpl实现类上忘加了service注解
https://blog.csdn.net/qq_41247433/article/details/82289924
②Result Maps collection already contains value for ...
原因在于使用逆向工程重复生成了xml文件,解决方法在于将mapper文件夹中的xml文件删干净后重新生成
https://blog.csdn.net/erpenggg/article/details/90440378
4、使用springboot集成的AOP:
首先需要导入包:spring-boot-starter-aop
并且可以使用@Order(顺序参数)注解来控制配置类的加载顺序