mybatis configuration

<?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:aop="http://www.springframework.org/schema/aop"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:task="http://www.springframework.org/schema/task"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="
     http://www.springframework.org/schema/beans
     http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
     http://www.springframework.org/schema/context
     http://www.springframework.org/schema/context/spring-context-3.2.xsd
     http://www.springframework.org/schema/aop
     http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
     http://www.springframework.org/schema/tx
     http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
     http://www.springframework.org/schema/jdbc
     http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd
     http://www.springframework.org/schema/task
     http://www.springframework.org/schema/task/spring-task-3.2.xsd">

	<!-- auto-wired -->
	<context:component-scan base-package="com.lasho.mybatis" />
	
	<context:annotation-config />
	
	<!-- prop-placeHolder -->
	<bean id="placeholderProperties"
		class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="locations">
		   <list>
				<value>classpath:db.properties</value>
		   </list>
		</property>
		<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
		<property name="ignoreUnresolvablePlaceholders" value="true" />
		<property name="order" value="1" />
		<property name="valueSeparator" value="?" />
	</bean>
	<!-- data-source -->
	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
		destroy-method="close">
		<property name="driverClassName" value="${db.driverClassName}" />
		<property name="url" value="${db.url}" />
		<property name="username" value="${db.username}" />
		<property name="password" value="${db.password}" />
	</bean>
	<!-- transaction-manager -->
	<tx:annotation-driven transaction-manager="transcationManager" />
	<bean id="transcationManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="dataSource" />
	</bean>

	<!-- define the SqlSessionFactory -->
	<bean id="sessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
		<property name="dataSource" ref="dataSource" />
		<!-- relative-path -->
		<property name="typeAliasesPackage" value="com.lasho.mybatis.domain" />
		<!-- mapper.xml locations -->
		<property name="mapperLocations" value="classpath*:com/lasho/mybatis/xmlmapper/*.xml"/>
	</bean>

	<!-- scan for mappers and let them be autowired -->
	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<!-- interface-package[ if xml&interface in the same path ,mapperLocations could not set] -->
		<property name="basePackage" value="com.lasho.mybatis.mapper" /> 
		<!-- many sqlSessionFactory -->
		<property name="sqlSessionFactoryBeanName" value="sessionFactory" />
	</bean>
	
	<!-- special-mapper-proxy -->
	<!-- <bean id="codeMapper" class="org.mybatis.spring.mapper.MapperFactoryBean"> 
      <property name="mapperInterface" value="com.lasho.mybatis.mapper.CodeMapper" />
      <property name="sqlSessionFactory" ref="sessionFactory" /> 
    </bean> -->
	
</beans>


----------- maper interface ---------
2014-02-14 16:20:53,250 DEBUG [main] support.PathMatchingResourcePatternResolver (PathMatchingResourcePatternResolver.java:550)     - Looking for matching resources in directory tree [D:\work\sts3.3\myBatisDemo\target\classes\com\lasho\mybatis\mapper]
2014-02-14 16:20:53,250 DEBUG [main] support.PathMatchingResourcePatternResolver (PathMatchingResourcePatternResolver.java:612)     - Searching directory [D:\work\sts3.3\myBatisDemo\target\classes\com\lasho\mybatis\mapper] for files matching pattern [D:/work/sts3.3/myBatisDemo/target/classes/com/lasho/mybatis/mapper/**/*.class]
2014-02-14 16:20:53,251 DEBUG [main] support.PathMatchingResourcePatternResolver (PathMatchingResourcePatternResolver.java:351)     - Resolved location pattern [classpath*:com/lasho/mybatis/mapper/**/*.class] to resources [file [D:\work\sts3.3\myBatisDemo\target\classes\com\lasho\mybatis\mapper\CodeMapper.class]]
2014-02-14 16:20:53,252 DEBUG [main] mapper.ClassPathMapperScanner (ClassPathScanningCandidateComponentProvider.java:264)     - Identified candidate component class: file [D:\work\sts3.3\myBatisDemo\target\classes\com\lasho\mybatis\mapper\CodeMapper.class]
2014-02-14 16:20:53,252 DEBUG [main] mapper.ClassPathMapperScanner (ClassPathMapperScanner.java:161)     - Creating MapperFactoryBean with name 'codeMapper' and 'com.lasho.mybatis.mapper.CodeMapper' mapperInterface
------------ mapper location -----------
2014-02-14 16:20:53,427 DEBUG [main] support.PathMatchingResourcePatternResolver (PathMatchingResourcePatternResolver.java:550)     - Looking for matching resources in directory tree [D:\work\sts3.3\myBatisDemo\target\classes\com\lasho\mybatis\xmlmapper]
2014-02-14 16:20:53,428 DEBUG [main] support.PathMatchingResourcePatternResolver (PathMatchingResourcePatternResolver.java:612)     - Searching directory [D:\work\sts3.3\myBatisDemo\target\classes\com\lasho\mybatis\xmlmapper] for files matching pattern [D:/work/sts3.3/myBatisDemo/target/classes/com/lasho/mybatis/xmlmapper/*.xml]
2014-02-14 16:20:53,429 DEBUG [main] support.PathMatchingResourcePatternResolver (PathMatchingResourcePatternResolver.java:351)     - Resolved location pattern [classpath*:com/lasho/mybatis/xmlmapper/*.xml] to resources [file [D:\work\sts3.3\myBatisDemo\target\classes\com\lasho\mybatis\xmlmapper\CodeMapper.xml]]
2014-02-14 16:20:53,431 DEBUG [main] support.DefaultListableBeanFactory (AbstractAutowireCapableBeanFactory.java:1531)     - Invoking afterPropertiesSet() on bean with name 'sessionFactory'
-----------  instance  ----------
2014-02-14 16:20:53,925 DEBUG [main] spring.SqlSessionFactoryBean (Slf4jImpl.java:47)     - Parsed mapper file: 'file [D:\work\sts3.3\myBatisDemo\target\classes\com\lasho\mybatis\xmlmapper\CodeMapper.xml]'
2014-02-14 16:20:53,926 DEBUG [main] support.DefaultListableBeanFactory (AbstractBeanFactory.java:246)     - Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
2014-02-14 16:20:53,927 DEBUG [main] support.DefaultListableBeanFactory (AbstractAutowireCapableBeanFactory.java:463)     - Finished creating instance of bean 'sessionFactory'
2014-02-14 16:20:53,927 DEBUG [main] support.DefaultListableBeanFactory (AbstractBeanFactory.java:246)     - Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
2014-02-14 16:20:53,936 DEBUG [main] support.DefaultListableBeanFactory (AbstractAutowireCapableBeanFactory.java:1531)     - Invoking afterPropertiesSet() on bean with name 'codeMapper'
2014-02-14 16:20:53,936 DEBUG [main] support.DefaultListableBeanFactory (AbstractBeanFactory.java:246)     - Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
2014-02-14 16:20:53,937 DEBUG [main] support.DefaultListableBeanFactory (AbstractAutowireCapableBeanFactory.java:463)     - Finished creating instance of bean 'codeMapper'
2014-02-14 16:20:53,938 DEBUG [main] support.DefaultListableBeanFactory (AbstractBeanFactory.java:246)     - Returning cached instance of singleton bean 'codeMapper'
2014-02-14 16:20:53,941 DEBUG [main] support.DefaultListableBeanFactory (AbstractBeanFactory.java:246)     - Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
2014-02-14 16:20:53,942 DEBUG [main] annotation.AutowiredAnnotationBeanPostProcessor (AutowiredAnnotationBeanPostProcessor.java:433)     - Autowiring by type from bean name 'codeServiceImpl' to bean named 'codeMapper'
2014-02-14 16:20:53,943 DEBUG [main] support.DefaultListableBeanFactory (AbstractBeanFactory.java:246)     - Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
2014-02-14 16:20:53,944 DEBUG [main] support.DefaultListableBeanFactory (AbstractAutowireCapableBeanFactory.java:463)     - Finished creating instance of bean 'codeServiceImpl'

你可能感兴趣的:(mybatis)