<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                >### 1.編寫spring的配置文件applicationContext.xml 步驟: - 1.只掃描 Service Repository Component - 2.配置外部的數據源文件位置 db.properties ~~~ jdbcUrl=jdbc:mysql://localhost:3306/ssm driverClass=com.mysql.jdbc.Driver user=root password=root ~~~ - 3.c3p0數據庫連接池 - 4.配置和mybatis的整合(sqlSessionFactoryBean) 指定三個屬性①.總的配置文件的位置 ②.指定數據源 ③.指定所有mapper映射文件的位置 - 5.配置掃描器(MapperScannerConfigurer),將dao的實現加入到ioc容器 - 6.配置一個可以執行批量的sqlSession(可選,主要用于測試插入數據,很多條數據) - 7.配置事務 aop切面 ~~~ <?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:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd"> <!-- 配置需要掃描的注解,都交給springIOC容器來統一管理 spring @Service @Repository @Component --> <context:component-scan base-package="cn.li"> <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/> </context:component-scan> <!-- spring的配置文件,這里主要配置和業務邏輯有關的 --> <!-- =========數據源 事務控制 xxx======== --> <context:property-placeholder location="classpath:db.properties"/> <!-- c3p0數據庫連接池 --> <bean id="pooledDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="jdbcUrl" value="${jdbcUrl}"></property> <property name="driverClass" value="${driverClass}"></property> <property name="user" value="${user}"></property> <property name="password" value="${password}"></property> </bean> <!-- ==========配置和MyBatis的整合======== --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <!-- 指定mybatis全局配置文件的位置 --> <property name="configLocation" value="classpath:mybatis-config.xml"></property> <property name="dataSource" ref="pooledDataSource"></property> <!-- 指定mybatis,mapper文件的位置 --> <property name="mapperLocations" value="classpath:mapper/*.xml"></property> </bean> <!--配置掃描器,將mybatis接口的實現加入到ioc容器中 --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <!--掃描所有dao接口的實現,加入到ioc容器中 --> <property name="basePackage" value="cn.li.crud.dao"></property> </bean> <!-- 配置一個可以執行批量的sqlSession --> <bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate"> <constructor-arg name="sqlSessionFactory" ref="sqlSessionFactory"></constructor-arg> <constructor-arg name="executorType" value="BATCH"></constructor-arg> </bean> <!-- ===============事務控制的配置 ================--> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <!--控制住數據源 --> <property name="dataSource" ref="pooledDataSource"></property> </bean> <!--開啟基于注解的事務,使用xml配置形式的事務(必要主要的都是使用配置式) --> <aop:config> <!-- 切入點表達式 --> <aop:pointcut expression="execution(* cn.li.crud.service..*(..))" id="txPoint"/> <!-- 配置事務增強 --> <aop:advisor advice-ref="txAdvice" pointcut-ref="txPoint"/> </aop:config> <!--配置事務增強,事務如何切入 --> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <!-- 所有方法都是事務方法 --> <tx:method name="*"/> <!--以get開始的所有方法 --> <tx:method name="get*" read-only="true"/> </tx:attributes> </tx:advice> <!-- Spring配置文件的核心點(數據源、與mybatis的整合,事務控制) --> </beans> ~~~ >### 2.編寫springmvc的配置文件dispatcherServlet-servlet.xml,放在WEN-INF目錄下 ![](https://box.kancloud.cn/816f6f194712b63e248eea2ddee7c18e_162x84.png) 步驟: - 1.springMVC的配置文件,包含網站跳轉邏輯的控制,配置,只掃描控制器 - 2.配置視圖解析器 - 3.兩個標準配置 ~~~ <?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" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd 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-4.3.xsd"> <!-- springMVC的配置文件,包含網站跳轉邏輯的控制,配置 --> <context:component-scan base-package="cn.li" use-default-filters="false"> <!-- 只掃描控制器 --> <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" /> </context:component-scan> <!-- 配置視圖解析器,方便頁面返回 --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/views/"></property> <property name="suffix" value=".jsp"></property> </bean> <!-- 兩個標準配置 --> <!-- 將springmvc不能處理的請求交給tomcat --> <mvc:default-servlet-handler/> <!-- 能支持springmvc更高級的一些功能,JSR303校驗,快捷的ajax...映射動態請求 --> <mvc:annotation-driven/> </beans> ~~~ >### 3.編寫mybatis的配置文件mybatis-config.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> <settings> <!-- 開啟駝峰命名規則 。。。 --> <setting name="mapUnderscoreToCamelCase" value="true" /> </settings> <typeAliases> <!-- 批量注冊別名。 --> <package name="cn.li.crud.bean" /> </typeAliases> <plugins> <plugin interceptor="com.github.pagehelper.PageInterceptor"> <!--分頁參數合理化 --> <property name="reasonable" value="true" /> </plugin> </plugins> </configuration> ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看