PooledDataSource forcefully closed/removed all connections的解决

 As shown in the figure, in MyBatis, when the one-to-one association of database tables is implemented, the test class test is run to report PooledDataSource forcefully closed/removed all connections. After step-by-step inspection, it is found that there are no errors in the test class and the mapping file mapper.xml. The mapper.xml file is also added and registered in the mybatis core file. There is no problem with the database configuration file.

After many inspections, it was found that the <setting> node was missing in the mybatis core file, and the <setting> node should be added below <properties> and above <typeAliases>.

solve:

join in

<settings>
    <setting name="autoMappingBehavior"  value="FULL"/>
//Indicates that the resultMap of the mapper file uses automatic mapping, and does not need to list all field names. (The reason is here, I omitted all the field names in the mapper file, but forgot to add this setting) (It’s really easy to forget bushi)
    <setting name="cacheEnabled" value="true"/>
//Use MyBatis cache to improve query efficiency
</settings>

Guess you like

Origin blog.csdn.net/weixin_56342559/article/details/129891596