application.xml
<!--扫描包—-> <context:compent-scan package="com.bdqn.exam"></context:compent-scan> <!--事务的工厂--> <bean class="org.springframework.jdbc.datasource.DataSourceTransactionManagert" id="transactionManagert" > <property name="dataSource" ref="dataSource"></property> </bean> <!--打开事务注解--> <tx:annotation-driven/> <!-- 打开mvc注解--> <mvc:annotation-driven/> <--jdbc数据源的配置工厂--> <bean> <property name="driverClass" value="com.mysql.jdbc.driver"> <property name="user" value="root"> <property name="password" value="123"> <property name="jdbcUrl" value="jdbc:mysql:///exam?characterEncoding=utf-8"> </bean> <!--mybatis工厂--> <bean class="org.mybatis.spring.SqlSessionFactoryBean" id="sqlsessionFactory"> <property name="dataSource" value="dataSource"></property> </bean> <!--帮助类工厂--> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"> <property name="basepackage" value="com.bdqn.exam.dao"> </bean>