<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      maven_SSM集成的demo

      一、集成spring

      二、集成springMVC

      三、集成mybatis

       

      1. pom.xml

      <?xml version="1.0" encoding="UTF-8"?>
      
      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
      
        <groupId>com.ddh.test</groupId>
        <artifactId>maven_ssm</artifactId>
        <version>1.0-SNAPSHOT</version>
        <packaging>war</packaging>
      
        <name>maven_ssm Maven Webapp</name>
        <!-- FIXME change it to the project's website -->
        <url>http://www.example.com</url>
      
        <properties>
          <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
          <maven.compiler.source>1.7</maven.compiler.source>
          <maven.compiler.target>1.7</maven.compiler.target>
            <srping.version>4.0.2.RELEASE</srping.version>
            <mybatis.version>3.2.8</mybatis.version>
            <slf4j.version>1.7.12</slf4j.version>
            <log4j.version>1.2.17</log4j.version>
        </properties>
      
        <dependencies>
          <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
          </dependency>
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>javax.servlet-api</artifactId>
                <version>3.1.0</version>
                <scope>provided</scope>
            </dependency>
      
            <!-- java ee包 -->
            <dependency>
                <groupId>javax</groupId>
                <artifactId>javaee-api</artifactId>
                <version>7.0</version>
                <scope>provided</scope>
            </dependency>
            <!-- spring框架包 start -->
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-test</artifactId>
                <version>${srping.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
                <version>${srping.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-oxm</artifactId>
                <version>${srping.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-tx</artifactId>
                <version>${srping.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-jdbc</artifactId>
                <version>${srping.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-aop</artifactId>
                <version>${srping.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
                <version>${srping.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context-support</artifactId>
                <version>${srping.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-expression</artifactId>
                <version>${srping.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-orm</artifactId>
                <version>${srping.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-web</artifactId>
                <version>${srping.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-webmvc</artifactId>
                <version>${srping.version}</version>
            </dependency>
            <!-- spring框架包 end -->
            <!-- mybatis框架包 start -->
            <dependency>
                <groupId>org.mybatis</groupId>
                <artifactId>mybatis</artifactId>
                <version>${mybatis.version}</version>
            </dependency>
            <dependency>
                <groupId>org.mybatis</groupId>
                <artifactId>mybatis-spring</artifactId>
                <version>1.2.2</version>
            </dependency>
            <!-- mybatis框架包 end -->
            <!-- 數據庫驅動 -->
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>5.1.35</version>
            </dependency>
            <!-- 導入dbcp的jar包,用來在applicationContext.xml中配置數據庫 -->
            <dependency>
                <groupId>commons-dbcp</groupId>
                <artifactId>commons-dbcp</artifactId>
                <version>1.4</version>
            </dependency>
            <!-- jstl標簽類 -->
            <dependency>
                <groupId>jstl</groupId>
                <artifactId>jstl</artifactId>
                <version>1.2</version>
            </dependency>
            <!-- log start -->
            <dependency>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
                <version>${log4j.version}</version>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>${slf4j.version}</version>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
                <version>${slf4j.version}</version>
            </dependency>
            <!-- log END -->
            <!-- Json  -->
            <!-- 格式化對象,方便輸出日志 -->
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>fastjson</artifactId>
                <version>1.2.6</version>
            </dependency>
            <dependency>
                <groupId>org.codehaus.jackson</groupId>
                <artifactId>jackson-mapper-asl</artifactId>
                <version>1.9.13</version>
            </dependency>
            <!-- 上傳組件包 start -->
            <dependency>
                <groupId>commons-fileupload</groupId>
                <artifactId>commons-fileupload</artifactId>
                <version>1.3.1</version>
            </dependency>
            <dependency>
                <groupId>commons-io</groupId>
                <artifactId>commons-io</artifactId>
                <version>2.4</version>
            </dependency>
            <dependency>
                <groupId>commons-codec</groupId>
                <artifactId>commons-codec</artifactId>
                <version>1.10</version>
            </dependency>
            <!-- 上傳組件包 end -->
        </dependencies>
      
        <build>
          <finalName>maven_ssm</finalName>
          <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
            <plugins>
              <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <version>3.0.0</version>
              </plugin>
              <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
              <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.0.2</version>
              </plugin>
              <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.7.0</version>
              </plugin>
              <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.20.1</version>
              </plugin>
              <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.2.0</version>
              </plugin>
              <plugin>
                <artifactId>maven-install-plugin</artifactId>
                <version>2.5.2</version>
              </plugin>
              <plugin>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.8.2</version>
              </plugin>
            </plugins>
          </pluginManagement>
        </build>
      </project>

      2. web.xml

      <!DOCTYPE web-app PUBLIC
       "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
       "http://java.sun.com/dtd/web-app_2_3.dtd" >
      
      <web-app >
        <display-name>Archetype Created Web Application</display-name>
          <!--1.1配置spring初始化路徑-->
          <context-param>
              <param-name>contextConfigLocation</param-name>
              <param-value>classpath:applicationContext.xml</param-value>
          </context-param>
          <!--1.2監聽器的方式,加載spring,這就是spring和tomcat的接口-->
          <listener>
              <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
          </listener>
      
          <!--配置springmvc的核心控制器-->
          <servlet>
              <servlet-name>springmvc</servlet-name>
              <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
              <init-param>
                  <param-name>contextConfigLocation</param-name>
                  <!--!!指定springMVC的配置文件-->
                  <param-value>classpath:applicationContext-mvc.xml</param-value>
              </init-param>
              <!--啟動級別,和服務器一起啟動-->
              <load-on-startup>1</load-on-startup>
          </servlet>
      
          <!--配置核心控制器映射,配置/意思是所有url都通過此servlet-->
          <servlet-mapping>
              <servlet-name>springmvc</servlet-name>
              <url-pattern>/</url-pattern>
          </servlet-mapping>
      </web-app>

      3. 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: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/context http://www.springframework.org/schema/context/spring-context.xsd
             http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
          ">
          <!--掃描service-->
          <context:component-scan base-package="com.daydayhave.ssm.service"/>
          <bean id="date" class="java.util.Date" />
      
          <!--引入mybatis-->
          <import resource="applicationContext-mybatis.xml" />
      
          <!-- 開啟spring對事務的注解支持 -->
          <tx:annotation-driven/>
      
      </beans>

      4. applicationContext-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:context="http://www.springframework.org/schema/context"
             xmlns:mvc="http://www.springframework.org/schema/mvc"
             xsi:schemaLocation="
             http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
             http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
             http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
          ">
          
          <!--掃描包 配置controller層的包掃描-->
          <context:component-scan base-package="com.daydayhave.ssm.web.controller"/>
          
          <!--靜態資源放行-->
          <mvc:default-servlet-handler/>
          <!--開啟springmvc注解支持-@RequestMapping-->
          <mvc:annotation-driven/>
      
          <!--文件上傳-->
          <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
              <!-- 設置上傳文件的最大尺寸為1MB -->
              <property name="maxUploadSize">
                  <!-- spring el寫法:5MB -->
                  <value>#{1024*1024*5}</value>
              </property>
          </bean>
          
          <!--視圖解析器:前后綴配置-->
          <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
              <!-- 前綴配置 -->
              <property name="prefix" value="/WEB-INF/jsps/" />
              <!-- 后綴配置 -->
              <property name="suffix" value=".jsp" />
          </bean>
      </beans>

      5. applicationContext-mybatis.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:context="http://www.springframework.org/schema/context"
             xsi:schemaLocation="
             http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
             http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
          ">
          
          <!--jdbc.properties  datasoruce(dbcp) SqlSessionFatory mapper servce junit 事務處理 web-->
          <context:property-placeholder location="classpath:jdbc.properties"/>
          <!--配置數據源-->
          <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
              <!--連接數據4個屬性 -->
              <property name="driverClassName" value="${jdbc.driverClassName}" />
              <property name="url" value="${jdbc.url}" />
              <property name="username" value="${jdbc.username}" />
              <property name="password" value="${jdbc.password}" />
              <!--maxActive: 最大連接數量 -->
              <property name="maxActive" value="150" />
              <!--minIdle: 最小空閑連接 -->
              <property name="minIdle" value="5" />
              <!--maxIdle: 最大空閑連接 -->
              <property name="maxIdle" value="20" />
              <!--initialSize: 初始化連接 -->
              <property name="initialSize" value="30" />
              <!-- 用來配置數據庫斷開后自動連接的 -->
              <!-- 連接被泄露時是否打印 -->
              <property name="logAbandoned" value="true" />
              <!--removeAbandoned: 是否自動回收超時連接 -->
              <property name="removeAbandoned" value="true" />
              <!--removeAbandonedTimeout: 超時時間(以秒數為單位) -->
              <property name="removeAbandonedTimeout" value="10" />
              <!--maxWait: 超時等待時間以毫秒為單位 1000等于60秒 -->
              <property name="maxWait" value="1000" />
              <!-- 在空閑連接回收器線程運行期間休眠的時間值,以毫秒為單位. -->
              <property name="timeBetweenEvictionRunsMillis" value="10000" />
              <!-- 在每次空閑連接回收器線程(如果有)運行時檢查的連接數量 -->
              <property name="numTestsPerEvictionRun" value="10" />
              <!-- 1000 * 60 * 30 連接在池中保持空閑而不被空閑連接回收器線程 -->
              <property name="minEvictableIdleTimeMillis" value="10000" />
              <property name="validationQuery" value="SELECT NOW() FROM DUAL" />
          </bean>
      
          <!--配置sqlSessionFactory-->
          <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
              <!--數據庫配置-->
              <property name="dataSource" ref="dataSource" />
              <!--別名就是mapper.xml中,不用謝類的全稱,直接寫 -->
              <property name="typeAliasesPackage" value="com.daydayhave.ssm.domain,com.daydayhave.ssm.query" />
              <!--映射文件-->
              <property name="mapperLocations" value="classpath:com/daydayhave/ssm/mapper/*Mapper.xml" />
          </bean>
      
          <!--掃描一個特定包,給該包下面所有的接口都產生一個以上的配置就ok
          掃描后  框架 會給這個包下的所有的mapper接口生成實現-->
          <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
              <property name="basePackage" value="com.daydayhave.ssm.mapper" />
          </bean>
          
      </beans>

      6. jdbc.properties

      jdbc.driverClassName = com.mysql.jdbc.Driver
      #company
      #house
      jdbc.url=jdbc:mysql:///testssm
      jdbc.username=z2
      jdbc.password=123456

       

      2.1 domain.java

      package com.daydayhave.ssm.domain;
      
      public class Department {
          private Long id;
          private String name;
      
          public Long getId() {
              return id;
          }
      
          public void setId(Long id) {
              this.id = id;
          }
      
          public String getName() {
              return name;
          }
      
          public void setName(String name) {
              this.name = name;
          }
      
          public Department() {
          }
      
          public Department(String name) {
      
              this.name = name;
          }
      }

      2.2 DepartmentMapper.java

      package com.daydayhave.ssm.mapper;
      
      
      import com.daydayhave.ssm.domain.Department;
      
      import java.util.List;
      
      public interface DepartmentMapper {
          List<Department> loadAll();
          void save(Department department);
      }

      2.3 DepartmentMapper.xml

      <?xml version="1.0" encoding="UTF-8" ?>
      <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
      <mapper namespace="com.daydayhave.ssm.mapper.DepartmentMapper" >
      <!-- List<Department> loadAll();
          void save(Department department); -->
          <select id="loadAll" resultType="Department">
              SELECT  * from t_department
          </select>
          <insert id="save" parameterType="Department">
              INSERT INTO t_department(name) values(#{name})
          </insert>
      </mapper>

      2.4 IDepartmentService.java

      package com.daydayhave.ssm.service;
      
      
      import com.daydayhave.ssm.domain.Department;
      
      import java.util.List;
      
      public interface IDepartmentService {
          List<Department> getAll();
          void add(Department department);
      }

      2.5 DepartmentServiceImpl.java

      package com.daydayhave.ssm.service.impl;
      
      
      import com.daydayhave.ssm.domain.Department;
      import com.daydayhave.ssm.mapper.DepartmentMapper;
      import com.daydayhave.ssm.service.IDepartmentService;
      import org.springframework.beans.factory.annotation.Autowired;
      import org.springframework.stereotype.Service;
      import org.springframework.transaction.annotation.Transactional;
      
      import java.util.List;
      
      @Service
      public class DepartmentServiceImpl implements IDepartmentService {
      
          @Autowired
          private DepartmentMapper departmentMapper;
          
          @Override
          public List<Department> getAll() {
              return departmentMapper.loadAll();
          }
      
          //寫事務:需要一個事務,并且不是只讀
          //@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
          @Transactional//默認就是寫事務
          @Override
          public void add(Department department) {
              departmentMapper.save(department);
              //int i = 1/0;
          }
      }

      3.1 baseTest.java

      package com.daydayhave.ssm;
      
      
      import org.junit.runner.RunWith;
      import org.springframework.test.context.ContextConfiguration;
      import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
      
      @RunWith(SpringJUnit4ClassRunner.class)
      @ContextConfiguration("classpath:applicationContext.xml")
      public class BaseTest {
      }

      3.2 DepartmentServiceImplTest.java

      package com.daydayhave.ssm.service.impl;
      
      import com.daydayhave.ssm.BaseTest;
      import com.daydayhave.ssm.domain.Department;
      import com.daydayhave.ssm.mapper.DepartmentMapper;
      import com.daydayhave.ssm.service.IDepartmentService;
      import org.junit.Test;
      import org.springframework.beans.factory.annotation.Autowired;
      
      import java.util.List;
      
      import static org.junit.Assert.*;
      
      public class DepartmentServiceImplTest extends BaseTest{
      
          @Autowired
          IDepartmentService departmentService;
      
          @Autowired
          DepartmentMapper departmentMapper;
      
          @Test
          public void getAll() {
              List<Department> departments = departmentService.getAll();
              System.out.println(departments);
          }
      
          @Test
          public void add() {
              System.out.println(departmentMapper);
          }
      }

      4.1 DepartmentController.java

      package com.daydayhave.ssm.web.controller;
      
      import org.springframework.stereotype.Controller;
      import org.springframework.web.bind.annotation.RequestMapping;
      
      @Controller
      @RequestMapping("/department")
      public class DepartmentController {
      
          //跳轉管理頁面
          @RequestMapping("/index")
          public String index(){
      
              return "department/index";
          }
      
      }

       

      posted @ 2018-12-08 22:55  乙侍  閱讀(250)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 国产内射性高湖| av午夜福利一片免费看久久| 亚洲精品综合久中文字幕| 中文字幕人妻日韩精品| 亚洲av无码成人精品区一区| 精品午夜福利在线视在亚洲| 久久综合久中文字幕青草| 亚洲乱熟乱熟女一区二区| 亚洲国产精品人人做人人爱| 免费国产高清在线精品一区| 国产愉拍精品手机| 国产激情一区二区三区在线| 东方四虎av在线观看| 综合色一色综合久久网| 亚洲精品入口一区二区乱| 免费又爽又大又高潮视频| 国产激情一区二区三区在线| 国产va免费精品观看| 18国产午夜福利一二区| 美女爽到高潮嗷嗷嗷叫免费网站| 成人亚洲av免费在线| 狠狠色综合久久丁香婷婷| 无码AV动漫精品一区二区免费| 成人自拍小视频免费观看| 美女把尿囗扒开让男人添| 亚洲精品国产第一区二区| 老鸭窝在钱视频| 亚洲精品成人一二三专区| 亚洲av色图一区二区三区| 欧美一性一乱一交一视频| 国产精品无遮挡猛进猛出| 久久这里精品国产99丫E6| 人妻熟女一区二区aⅴ向井蓝| 9lporm自拍视频区| 中文字幕国产精品日韩| 久久亚洲精品无码播放| 久久这里只有精品免费首页| 野花香视频在线观看免费高清版| 国产成人一区二区免av| 二区三区国产在线观看| 亚洲一区二区中文字幕|