ssm框架整合

1)Dao层

           pojo和映射文件以及接口使用逆向工程生成

           SqlMapConfig.xml   mybatis核心配置文件

           ApplicationContext-dao.xml 整合后spring在dao层的配置

                 数据源

                 会话工厂

                 扫描Mapper

2)service层

           事务                ApplicationContext-trans.xml

           @Service注解扫描   ApplicationContext-service.xml

3)controller层

           SpringMvc.xml

                 注解扫描:扫描@Controller注解

                 注解驱动:替我们显示的配置了最新版的处理器映射器和处理器适配器

                 视图解析器:显示的配置是为了在controller中不用每个方法都写页面的全路径

4)web.xml

           springMvc前端控制器配置

           spring监听

配制文件内容补充:

1.1.1  sqlMapConfig.xml

1.1.2 applicationContext-dao.xml

1.1.3  Db.properties

1.1.4  applicationContext-service.xml

1.1.5  applicationContext-transaction.xml

<?xmlversion="1.0"encoding="UTF-8"?>

<beansxmlns="http://www.springframework.org/schema/beans"

      xmlns:context="http://www.springframework.org/schema/context"xmlns:p="http://www.springframework.org/schema/p"

      xmlns:aop="http://www.springframework.org/schema/aop"xmlns:tx="http://www.springframework.org/schema/tx"

      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-4.0.xsd

      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd

      http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd

      http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd">

      <!-- 事务管理器 -->

      <beanid="transactionManager"

           class="org.springframework.jdbc.datasource.DataSourceTransactionManager">

           <!-- 数据源 -->

           <propertyname="dataSource"ref="dataSource"/>

      </bean>

      <!-- 通知 -->

      <tx:adviceid="txAdvice"transaction-manager="transactionManager">

           <tx:attributes>

                 <!-- 传播行为 -->

                 <tx:methodname="save*"propagation="REQUIRED"/>

                 <tx:methodname="insert*"propagation="REQUIRED"/>

                 <tx:methodname="delete*"propagation="REQUIRED"/>

                 <tx:methodname="update*"propagation="REQUIRED"/>

                 <tx:methodname="find*"propagation="SUPPORTS"read-only="true"/>

                 <tx:methodname="get*"propagation="SUPPORTS"read-only="true"/>

           </tx:attributes>

      </tx:advice>

      <!-- 切面 -->

      <aop:config>

           <aop:advisoradvice-ref="txAdvice"

                 pointcut="execution(* cn.itcast.springmvc.service.*.*(..))"/>

      </aop:config>

</beans>

1.1.6  springmvc.xml

1.1.7  web.xml

 

原文地址:https://www.cnblogs.com/txf0324/p/11149548.html