企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
<?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:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> ​ \<!-- 引入db.properties --> <context:property-placeholder location="classpath:db.properties" system-properties-mode="FALLBACK" /> ​ \<!-- 声明dataSource --> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> \<!-- 注入连接属性 --> <property name="driverClassName" value="${driverClassName}"></property> <property name="url" value="${url}"></property> <property name="username" value="${username}"></property> <property name="password" value="${password}"></property> </bean> \<!-- 声明sessionFactory 并注入mybatis.cfg.xml --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> \<!-- 注入数据源 --> <property name="dataSource" ref="dataSource"></property> \<!-- 注入mapper.xml --> <property name="mapperLocations"> <array> <value>classpath:mapper/\*Mapper.xml</value> </array> </property> </bean> ​ \<!-- 扫描mapper接口 --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> \<!-- 注入mapper接口所在的包 注意多个包的情况的配置 --> <property name="basePackage"> <value> com.sxt.mapper </value> </property> \<!-- 注入sqlSessionFactory --> <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property> </bean> </beans> ​