有没有spring与mybatis的整合包
<dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>${mybatis.spring.version}</version> </dependency>export_dao
(1)properties/db.properties(2)spring/applicationContext.xml(3)定义ICompanyDao(4)定义ICompanyDao.xml(5)测试子工程,dao子工程的交给spring管理,创建一个对应的applicationContext-dao.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:context="http://www.springframework.org/schema/context" 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"> <!--读取db.properties文件--> <context:property-placeholder location="classpath:properties/db.properties"></context:property-placeholder> <!--1.配置数据源--> <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"> <property name="url" value="${jdbc.url}"/> <property name="driverClassName" value="${jdbc.driver}"/> <property name="username" value="${jdbc.username}"/> <property name="password" value="${jdbc.password}"/> </bean> <!--2.配置Spring整合Mybatis *** 由Spring创建SqlSessionFactory对象--> <!--2.1 配置SqlSessionFactoryBean--> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <!--注入数据源--> <property name="dataSource" ref="dataSource"/> <!-- com.wzx.domain.company.Company company--> <property name="typeAliasesPackage" value="com.wzx.domain"/> </bean> <!--2.2 配置Dao接口所在包 动态代理 session.getMapper(Dao.class)--> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <!--指定Dao接口所在包--> <property name="basePackage" value="com.wzx.dao"/> </bean> </beans>