SSM配置
<?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:p="http://www.springframework.org/schema/p"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
						http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
						http://www.springframework.org/schema/context
           				http://www.springframework.org/schema/context/spring-context-3.1.xsd
  						http://www.springframework.org/schema/tx
  						http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
						http://www.springframework.org/schema/aop 
						http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
	
	<!-- 读取properties配置文件 -->
	<context:property-placeholder location="classpath:jdbc.properties"/>
	
	<!--(使用dbcp连接池) 
		 destroy-method:銷毀的方法
		 scope:一個連接池,要保持單例的模式
	-->  
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" 
    	  destroy-method="close" 
    	  scope="singleton">
	    <property name="driverClassName" value="${driver}"/>
	    <property name="url" value="${url}"/>
	    <property name="username" value="${uname}"/>	<!--value值不是username-->
	    <property name="password" value="${password}"/>
 	</bean>
 	<!-- 让事务的注解起效 -->
 	<tx:annotation-driven/>
 	<!-- 事务管理 -->  
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">  
        <property name="dataSource" ref="dataSource" />  
    </bean> 
    
    <!-- 配置mybatis的 sqlSessionFactory -->  
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">  
        <property name="dataSource" ref="dataSource" />  
        <property name="configLocation" value="classpath:mybatis-configuration.xml" />
    </bean>
    <!-- Mapper接口所在包名,Spring会自动查找其下的Mapper -->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">  
        <property name="basePackage" value="com.prj.dao" />  
    </bean>
</beans>
一、编辑jdbc.properties文件
二、mybatis的配置
	a.配置实体类的 包名
	
三、spring mvc的配置
	a.自动扫描注解
	b.视图解析器
	
四、spring的配置文件
	a.读取properties配置文件
	b.配置数据源
	c.配置事务
	d.配置mybatis的 sqlSessionFactory
	e.配置数据访问层,接口和映射配置。
五、web.xml
	a.加载spring的相关配置文件
	b.加载spring mvc的相关配置文件
	c.配置spring的监听器
	d.配置字符编码
	
注意事项(和以前写法不同的地方)
	a.业务逻辑层的实现类要添加@Service注解,
	    并且业务逻辑层的实现类下的数据访问层的属性要添加@Resource注解
	    这样的话不用去new,也不用去依赖注入
	b.在控制层中业务逻辑层的属性要添加@Resource注解
 
                    
                 
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号