Fixing the ‘sqlSessionFactory or sqlSessionTemplate’ Required Error in Spring Boot MyBatis Integration
The article explains why a Spring Boot project using MyBatis may throw the ‘Property sqlSessionFactory or sqlSessionTemplate are required’ error and provides two concrete fixes: downgrade the spring-boot-starter-parent version and switch the MySQL driver from 8.x to 5.7.
When integrating MyBatis into a Spring Boot project the runtime may throw the error “Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required”. The article explains that this typically occurs because of incompatibilities between the Spring Boot starter version and the MySQL driver.
Solution 1 – downgrade Spring Boot starter: Reduce the spring-boot-starter-parent version (e.g., from 3.x to 2.x), delete the existing jar files from the local Maven repository, and let Maven re‑download the correct artifacts.
Solution 2 – adjust MySQL driver version: Change the MySQL dependency from 8.x to 5.7, which matches the older Spring Boot version and satisfies MyBatis’s expectations.
After applying these changes and rebuilding the project, the application starts without the missing‑property error.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Coder Trainee
Experienced in Java and Python, we share and learn together. For submissions or collaborations, DM us.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
