Springboot uses Oracle database to report property ‘sqlsessionfactory’ or ‘sqlsessiontemplate’ are required

The first time I used springboot to do a project, this mistake is very simple, but it took me more than two hours to solve it.!!

1. According to the Convention, write a test class to test whether the connection to the database is successful

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import javax.sql.DataSource;

class SpringbootThymeleaf001ApplicationTests {

	//Test database connection
	DataSource dataSource;
	void contextLoads() throws Exception{
		System.out.println("The database connection obtained is :"+dataSource.getConnection());


The connection was tested at the beginning and the connection was successful. Then, when I started the project, there was an error, so I turned back and tested the connection again, and even reported an error!! Nothing changed in the middle!
2. Solutions


Replace the above dependency with the following dependency, successfully solved!


Read More: