llm-survey/backend/target/classes/spring/spring-mybatis.xml

65 lines
3.0 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
<!-- 配置数据源 -->
<bean id="dataSource" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
<property name="driverClassName" value="${jdbc.driver}"/>
<property name="jdbcUrl" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
<!-- 连接池配置 -->
<property name="minimumIdle" value="${jdbc.pool.minimumIdle}"/>
<property name="maximumPoolSize" value="${jdbc.pool.maximumPoolSize}"/>
<property name="idleTimeout" value="${jdbc.pool.idleTimeout}"/>
<property name="connectionTimeout" value="${jdbc.pool.connectionTimeout}"/>
<property name="connectionTestQuery" value="${jdbc.pool.connectionTestQuery}"/>
<!-- 其他配置 -->
<property name="autoCommit" value="true"/>
<property name="poolName" value="HikariPool-Survey"/>
<property name="maxLifetime" value="1800000"/>
<property name="validationTimeout" value="5000"/>
<property name="leakDetectionThreshold" value="60000"/>
</bean>
<!-- 配置SqlSessionFactory -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="configLocation" value="classpath:mybatis/mybatis-config.xml"/>
<property name="mapperLocations" value="classpath*:mybatis/mapper/*.xml"/>
<!-- 配置插件 -->
<property name="plugins">
<array>
<!-- 分页插件 -->
<bean class="com.github.pagehelper.PageInterceptor">
<property name="properties">
<value>
helperDialect=mysql
reasonable=true
supportMethodsArguments=true
params=count=countSql
</value>
</property>
</bean>
</array>
</property>
</bean>
<!-- 配置Mapper扫描器 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="ltd.qubit.survey.dao"/>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
</bean>
<!-- 配置事务管理器 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
</beans>