国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

ssm整合的配置文件

2019-11-08 20:09:41
字體:
來源:轉載
供稿:網友

applicationContext.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:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p" 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/tx  http://www.springframework.org/schema/tx/spring-tx-3.2.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd"> <!-- 配置數據源,記得去掉myBatis-config.xml的數據源相關配置 --> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">  <property name="driverClass" value="com.MySQL.jdbc.Driver" />  <property name="jdbcUrl"   value="jdbc:mysql://localhost:3306/scm?useUnicode=true&amp;characterEncoding=UTF-8" />  <property name="user" value="root" />  <property name="passWord" value="951207" /> </bean> <!-- 配置session工廠 --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">  <property name="dataSource" ref="dataSource" />  <property name="configLocation" value="classpath:myBatis-config.xml" />  <!--配置掃描式加載SQL映射文件,記得去掉mybatis-config配置-->  <property name="mapperLocations" value="classpath:com.jinhuan.scm.dao*.xml"/>   </bean> <!-- 配置事務管理器,管理數據源事務處理 --> <bean id="transactionManager"  class="org.springframework.jdbc.datasource.DataSourceTransactionManager">  <property name="dataSource" ref="dataSource" /> </bean> <!-- 配置事務通知 --> <tx:advice id="advice" transaction-manager="transactionManager">  <tx:attributes>   <!-- 默認只處理運行時異常,可加rollback-for="Exception/Throwable"等處理所有異常或包括錯誤 -->   <tx:method name="insert*" propagation="REQUIRED"    rollback-for="Exception" />   <tx:method name="update*" propagation="REQUIRED"    rollback-for="Exception" />   <tx:method name="delete*" propagation="REQUIRED"    rollback-for="Exception" />   <tx:method name="*" propagation="SUPPORTS" />  </tx:attributes> </tx:advice> <!-- 配置切面織入的范圍,后邊要把事務邊界定在service層 --> <aop:config>  <aop:advisor advice-ref="advice"   pointcut="execution(* com.jinhuan.scm.service.impl.*.*(..))" /> </aop:config> <!-- 配置SessionTemplate,已封裝了繁瑣的數據操作 --> <bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">  <constructor-arg name="sqlSessionFactory" ref="sqlSessionFactory" /> </bean> <!-- <context:component-scan base-package="*" /> --> <!-- 自動掃描組件,要把controller去除,他們是在spring-mvc.xml中配置,如果不去除會影響事務管理。 --> <context:component-scan base-package="com.jinhuan.scm">  <context:exclude-filter type="annotation"   expression="org.springframework.stereotype.Controller" /> </context:component-scan> <!-- 配置 轉換器,對于在basePackage設置的包(包括子包)下的接口類, 如果接口類的全類名在Mapper.xml文件中和定義過命名空間一致,  將被轉換成spring的BEAN,在調用   的地方通過@Autowired方式將可以注入接口實例 --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">  <property name="sqlSessionFactory" ref="sqlSessionFactory" />  <property name="basePackage" value="com.jinhuan.scm.dao" /> </bean></beans>Spring-mvc.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:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p" 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/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd "> <!-- 同時開啟json格式的支持 --> <mvc:annotation-driven></mvc:annotation-driven> <!-- <context:component-scan base-package="*"/> -->  <!-- 掃描所有的controller 但是不掃描service --> <context:component-scan base-package="com.jinhuan.scm">  <context:include-filter type="annotation"   expression="org.springframework.stereotype.Controller" />  <context:exclude-filter type="annotation"   expression="org.springframework.stereotype.Service" /> </context:component-scan>   </beans>sqlMapConfig.xml<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"><configuration> <typeAliases>  <package name="com.jinhuan.scm.entity" /> </typeAliases></configuration>web.xml<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">  <display-name>scm4</display-name>   <listener>    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  </listener>  <context-param>    <param-name>contextConfigLocation</param-name>    <param-value>classpath:applicationContext.xml</param-value>  </context-param>  <servlet>    <servlet-name>mvc</servlet-name>    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>    <init-param>      <param-name>contextConfigLocation</param-name>      <param-value>classpath:spring-mvc.xml</param-value>    </init-param>    <load-on-startup>1</load-on-startup>  </servlet>  <servlet-mapping>    <servlet-name>mvc</servlet-name>    <url-pattern>*.action</url-pattern>  </servlet-mapping>  <filter>    <filter-name>encodingFilter</filter-name>    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>    <init-param>      <param-name>encoding</param-name>      <param-value>UTF-8</param-value>    </init-param>  </filter>  <filter-mapping>    <filter-name>encodingFilter</filter-name>    <url-pattern>/*</url-pattern>  </filter-mapping>  <welcome-file-list>    <welcome-file>login.jsp</welcome-file>  </welcome-file-list></web-app>jar包下載地址:http://download.csdn.net/detail/rosener/9755358


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 新建县| 枝江市| 沁阳市| 东乡族自治县| 高平市| 京山县| 营山县| 桐城市| 罗山县| 水富县| 江门市| 古蔺县| 定边县| 阿拉善右旗| 塘沽区| 垣曲县| 定兴县| 嘉黎县| 马关县| 吴江市| 锡林郭勒盟| 桓台县| 米脂县| 漯河市| 个旧市| 五家渠市| 黄山市| 波密县| 吐鲁番市| 乌苏市| 乌兰浩特市| 象州县| 建水县| 伊川县| 苏州市| 汽车| 孟津县| 万州区| 大埔县| 夹江县| 道孚县|