spring 核心配置文件(applicationContext.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" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <!--配置数据源--> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"/> <property name="url" value="jdbc:mysql://localhost:3306/mybatis?useSSL=true&useUnicode=true&characterEncoding=utf-8"/> <property name="username" value="root"/> <property name="password" value="123456"/> </bean> <!--配置SqlSessionFactoryBean--> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <!--注入数据源--> <property name="dataSource" ref="dataSource"/> <!--配置别名--> <property name="typeAliases" value="com.kuang.pojo.User"/> <!--引入mapper文件--> <property name="mapperLocations" value="classpath:com/kuang/mapper/*.xml"/> </bean> <bean id="userMapper" class="com.kuang.mapper.impl.UserMapperImpl"> <!--注入sqlSessionFactoryBean--> <property name="sqlSessionFactory" ref="sqlSessionFactory"/> </bean> </beans>