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.

Coder Trainee
Coder Trainee
Coder Trainee
Fixing the ‘sqlSessionFactory or sqlSessionTemplate’ Required Error in Spring Boot MyBatis Integration

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.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

spring-bootMySQLMyBatissqlSessionTemplatesqlSessionFactorydependency version
Coder Trainee
Written by

Coder Trainee

Experienced in Java and Python, we share and learn together. For submissions or collaborations, DM us.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.