Is there any way to do a customizable timeout for MyBatis configuration?
I am using MyBatis with Spring framework, but I cannot make the 'defaultStatementTimeout' property customizable, as PropertyPlaceHolder on Spring.
There is a way, but only through of the MyBatis configuration file. You can add the location of MyBatis configuration file in your Spring configuration file (there is a example in the MyBatis page) for load the settings that you want:
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="location" value="classpath:mybatis-config.xml" />
</bean>
The MyBatis configuration file can be:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<settings>
<setting name="defaultStatementTimeout" value="10"/> <!-- seconds -->
</settings>
</configuration>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With