Common problems of integrating springmvc, mybatis, thymeleaf and Lombok in springboot (1)

Time:2021-7-21

Question 1:

Template not found or path incorrect
template might not exist or might not be accessible by any of the configured Template Resolvers
Common problems of integrating springmvc, mybatis, thymeleaf and Lombok in springboot (1)
Figure 1-1
answer:
1. Check whether there is a corresponding method under the path, that is, whether the path is correct
2. If the first step is correct, check whether you want to return data of collection / object type. If it is, you need to add @ ResponseBody annotation, otherwise spring MVC container will automatically parse back to view format, as shown in Figure 1-2
Common problems of integrating springmvc, mybatis, thymeleaf and Lombok in springboot (1)
Figure 1-2

Question 2:

Lombok adds @ data annotation without automatically generating get and set methods
answer:
After adding Lombok dependency to pom.xml, idea needs to download a Lombok plug-in to generate get and set methods, as shown in Figure 1-3
Common problems of integrating springmvc, mybatis, thymeleaf and Lombok in springboot (1)
Figure 1-3

Question 3:

Data binding exception, as shown in Figure 1-4:
Common problems of integrating springmvc, mybatis, thymeleaf and Lombok in springboot (1)
Figure 1-4
answer:
This is because mybatis can’t find the annotation of the operation database corresponding to the class or the corresponding XML file when injecting the object for you. Check whether the namespace of mapper is completely corresponding to the class you wrote, including the package name and the return type, as shown in Figure 1-5
Common problems of integrating springmvc, mybatis, thymeleaf and Lombok in springboot (1)
Figure 1-5

Question 4:

Type definition exception
Common problems of integrating springmvc, mybatis, thymeleaf and Lombok in springboot (1)
Figure 1-6
answer:
(1) There are no get and set methods, which are generated by Lombok or written manually

Question 5:

Today, I was pitied by the mapping of mybatis. I have been solving the problem of binding exception all afternoon
Common problems of integrating springmvc, mybatis, thymeleaf and Lombok in springboot (1)
answer:
(1) The common solution is to find out whether the XML file mapping corresponds to your Dao, and check whether the mapper’s namespace and SQL statement’s resulttype correspond to POJO
(2) Today, we found an unusual and hard to find binding exception, as shown in Figure 1-7. You should be careful when creating a directory in the resources directory. You can’t create a folder one by one just like in a java file. Write it here and record it!!!
Common problems of integrating springmvc, mybatis, thymeleaf and Lombok in springboot (1)
Figure 1-7