mybatis+spring
https://blog.csdn.net/qq_42371269/article/details/83505269
<!-- 1) 读取properties中的内容--> <context:property-placeholder location="classpath:jdbc.properties"/> <!-- 2) 数据库连接池 --> <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"> <property name="driverClassName" value="${drivername}"/> <property name="url" value="${url}"/> <property name="username" value="${jdbc.username}"/> <property name="password" value="${password}"/> <property name="maxActive" value="${max}"/> <property name="minIdle" value="${min}"/> </bean> <!-- 3) 获取 SqlSessionFactory 工厂类--> <bean id="sessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> </bean> <!-- 4) 搜索有哪些 mapper 实现类,把mapper接口自动配置成 spring 中的 <bean>--> <bean id="scannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <!-- name="basePackage":(起始)包名, 从这个包开始扫描--> <property name="basePackage" value="com.chen.mapper"/> </bean>