SpringMVC + Mybatis整合

参考:
mybatis学习笔记 http://legend2011.blog.51cto.com/3018495/888848
Mybatis整合Spring http://haohaoxuexi.iteye.com/blog/1843309
mybatis初步----查询之resultMap和resultType http://my.oschina.net/mutianya/blog/168268
mybatis自增主键配置 http://leeyee.github.io/blog/2013/08/22/mybatis-auto-increment-primary-key/
Spring声明式事务管理示例——MyBatis http://legend2011.blog.51cto.com/3018495/1239139
数据库逆向框架代码生成工具:MyBatis Generator的使用 http://my.oschina.net/lujianing/blog/200135

web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
		  http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
         version="3.0">

    <display-name>Archetype Created Web Application</display-name>
    <listener>
        <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
    </listener>
    <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>springmvc</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>springmvc</servlet-name>
        <url-pattern>*.do</url-pattern>
    </servlet-mapping>
</web-app>



servlet.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/mvc
    	http://www.springframework.org/schema/mvc/spring-mvc.xsd
    	http://www.springframework.org/schema/context
    	http://www.springframework.org/schema/context/spring-context.xsd">
    <context:component-scan base-package="com">
        <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
        <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service"/>
        <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Repository"/>
    </context:component-scan>
    <mvc:annotation-driven/>

    <mvc:resources location="/resources/" mapping="/resources/**"/>

    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="requestContextAttribute" value="rc"/>
        <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
        <property name="prefix" value="/"/>
        <property name="suffix" value=".jsp"/>
    </bean>
</beans>


jdbc.properties
jdbc.dataSource=com.alibaba.druid.pool.DruidDataSource
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/smartsangbag?useUnicode=true&amp;characterEncoding=utf8
jdbc.username=xxxxxxx
jdbc.password=******


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:mvc="http://www.springframework.org/schema/mvc"
       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.0.xsd
     http://www.springframework.org/schema/mvc
     http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
    <context:component-scan base-package="com.pandy"/>
    <context:property-placeholder location="classpath:/jdbc.properties"/>
    <bean id="dataSource" class="${jdbc.dataSource}">
        <property name="driverClassName" value="${jdbc.driver}"/>
        <property name="url" value="${jdbc.url}"/>
        <property name="username" value="${jdbc.username}"/>
        <property name="password" value="${jdbc.password}"/>
        <!-- <property name="alias" value="${proxool.alias}" />
        <property name="houseKeepingTestSql" value="${proxool.houseKeepingTestSql}" />
        <property name="prototypeCount" value="${proxool.prototypeCount}" />
        <property name="minimumConnectionCount" value="${proxool.minimumConnectionCount}" />
        <property name="maximumActiveTime" value="3600000" /> -->
    </bean>
</beans>



applicationContext-spring.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:context="http://www.springframework.org/schema/context"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:util="http://www.springframework.org/schema/util"
       xmlns:p="http://www.springframework.org/schema/p"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
    	http://www.springframework.org/schema/beans/spring-beans.xsd
    	http://www.springframework.org/schema/tx
    	http://www.springframework.org/schema/tx/spring-tx.xsd
    	http://www.springframework.org/schema/context
    	http://www.springframework.org/schema/context/spring-context.xsd
    	http://www.springframework.org/schema/aop
    	http://www.springframework.org/schema/aop/spring-aop.xsd
    	http://www.springframework.org/schema/util
    	http://www.springframework.org/schema/util/spring-util.xsd">

    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="mapperLocations" value="classpath:com/pandy/mapper/*.xml"/>
        <property name="typeAliasesPackage" value="com.pandy.model" />
    </bean>

    <!--  定义dao底层类  -->
    <bean id="sentEmailQueueMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
        <property name="mapperInterface" value="com.pandy.dao.mapper.SentEmailQueueMapper" />
        <property name="sqlSessionFactory" ref="sqlSessionFactory" />
    </bean>


    <!-- 定义事务 -->
    <bean id="transactionManager"
          class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource"/>
    </bean>
    <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>

</beans>


定义mybatis的映射文件 src/main/resources/com/pandy/mapper/SentEmailQueueMapper.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.pandy.dao.mapper.SentEmailQueueMapper">
    <resultMap type="com.pandy.model.SentEmailQueue" id="sentEmailQueueMap">
        <id column="data_id" property="dataId"/>
        <result column="from_email" property="fromEmail"/>
        <result column="to_email" property="toEmail"/>
        <result column="to_user_id" property="toUserId"/>
        <result column="send_date_time" property="sendDateTime"/>
        <result column="invalid_date_time" property="invalidDateTime"/>
        <result column="email_type" property="emailType"/>
        <result column="email_data_id" property="emailDataId"/>
        <result column="subject" property="subject"/>
        <result column="template_name" property="templateName"/>
        <result column="content_params" property="contentParams"/>
        <result column="sent_status" property="sentStatus"/>
        <result column="actual_sent_date_time" property="actualSentDateTime"/>
        <result column="CREATED_TIME" property="createdTime"/>
        <result column="MODIFIED_TIME" property="modifiedTime"/>
        <result column="LAST_UPDATED_STAMP" property="lastUpdatedStamp"/>
        <result column="LAST_UPDATED_TX_STAMP" property="lastUpdatedTxStamp"/>
        <result column="CREATED_STAMP" property="createdStamp"/>
        <result column="CREATED_TX_STAMP" property="createdTxStamp"/>
    </resultMap>

    <!--  一种映射方式,注意as后面的名字要跟model的属性名字一样 -->
    <select id="get" parameterType="int" resultType="com.pandy.model.SentEmailQueue">
        SELECT data_id as dataId, from_email as fromEmail, to_email as toEmail, to_user_id as toUserId, send_date_time as sendDateTime, invalid_date_time as invalidDateTime, email_type as emailType, email_data_id as emailDataId,
        subject as subject, template_name as templateName, content_params as contentParams, sent_status as sentStatus,
        actual_sent_date_time as actualSentDateTime,
        CREATED_TIME as createdTime,
        MODIFIED_TIME as modifiedTime,
        LAST_UPDATED_STAMP as lastUpdatedStamp,
        LAST_UPDATED_TX_STAMP as lastUpdatedTxStamp,
        CREATED_STAMP as createdStamp,
        CREATED_TX_STAMP as createdTxStamp
        FROM send_email_queue1 where data_id = #{data_id}
    </select>

    <!--  另一种映射方式,直接映射到model的类 -->
    <select id="getAll" resultMap="sentEmailQueueMap">
        SELECT data_id, from_email, to_email, to_user_id, send_date_time, invalid_date_time, email_type, email_data_id, subject, template_name, content_params, sent_status, actual_sent_date_time, CREATED_TIME, MODIFIED_TIME, LAST_UPDATED_STAMP, LAST_UPDATED_TX_STAMP, CREATED_STAMP, CREATED_TX_STAMP FROM send_email_queue1
    </select>



    <insert id="insert" parameterType="com.pandy.model.SentEmailQueue" useGeneratedKeys="true" keyProperty="dataId">
        INSERT INTO send_email_queue1 (from_email, to_email)
        VALUES (#{toEmail}, #{toEmail})
    </insert>
    <update id="update" parameterType="com.pandy.model.SentEmailQueue">
        UPDATE send_email_queue1 SET  from_email = #{toEmail}, to_email = #{toEmail}
        WHERE data_id = #{dataId}

    </update>
    <delete id="delete" parameterType="int">
        delete from send_email_queue1 where data_id = #{dataId}
    </delete>

</mapper>

映射文件对应的接口
package com.pandy.dao.mapper;

import com.pandy.model.SentEmailQueue;

import java.util.List;

/**
 * 只定义跟xml文件的sql对应就好,不用实现这个接口,这个接口mybatis自己实现。
 */
public interface SentEmailQueueMapper {

    public SentEmailQueue get(Integer id);
    public List<SentEmailQueue> getAll();

    public void insert(SentEmailQueue queue);
    public void update(SentEmailQueue queue);
    public void delete(Integer dataId);
}

映射文件对应的model
package com.pandy.model;

import java.util.Date;
public class SentEmailQueue {
    private Integer dataId;
    private String fromEmail;
    private String toEmail;
    private String toUserId;
    private Date sendDateTime;
    private Date invalidDateTime;
    private String emailType;
    private String emailDataId;
    private String subject;
    private String templateName;
    private String contentParams;
    private String sentStatus;
    private String actualSentDateTime;

    private Date createdTime;
    private Date modifiedTime;
    private Date lastUpdatedStamp;
    private Date lastUpdatedTxStamp;
    private Date createdStamp;
    private Date createdTxStamp;

    ......

    @Override
    public String toString() {
        return "SentEmailQueue{" +
                "dataId='" + dataId + '\'' +
                ", fromEmail='" + fromEmail + '\'' +
                ", toEmail='" + toEmail + '\'' +
                ", toUserId='" + toUserId + '\'' +
                ", sendDateTime=" + sendDateTime +
                ", invalidDateTime=" + invalidDateTime +
                ", emailType='" + emailType + '\'' +
                ", emailDataId='" + emailDataId + '\'' +
                ", subject='" + subject + '\'' +
                ", templateName='" + templateName + '\'' +
                ", contentParams='" + contentParams + '\'' +
                ", sentStatus='" + sentStatus + '\'' +
                ", actualSentDateTime='" + actualSentDateTime + '\'' +
                ", createdTime=" + createdTime +
                ", modifiedTime=" + modifiedTime +
                ", lastUpdatedStamp=" + lastUpdatedStamp +
                ", lastUpdatedTxStamp=" + lastUpdatedTxStamp +
                ", createdStamp=" + createdStamp +
                ", createdTxStamp=" + createdTxStamp +
                '}';
    }
}



DAO:
package com.pandy.dao;

import com.pandy.model.SentEmailQueue;

import java.util.List;

/**
 * Created by pandy on 14-8-13.
 */
public interface SentEmailQueueDao {
    public SentEmailQueue get(Integer dataId);
    public List<SentEmailQueue> getAll();

    public void insert(SentEmailQueue queue);
    public void update(SentEmailQueue queue);
    public void delete(Integer dataId);
}


package com.pandy.dao.impl;

import com.pandy.dao.SentEmailQueueDao;
import com.pandy.dao.mapper.SentEmailQueueMapper;
import com.pandy.model.SentEmailQueue;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by pandy on 14-8-13.
 */
@Repository("sentEmailQueueDao")
public class SentEmailQueueDaoImpl implements SentEmailQueueDao {
    @Resource
    private SentEmailQueueMapper sentEmailQueueMapper;

    @Override
    public SentEmailQueue get(Integer dataId) {
        return sentEmailQueueMapper.get(dataId);
    }

    @Override
    public List<SentEmailQueue> getAll() {
        return sentEmailQueueMapper.getAll();
    }

    @Override
    public void insert(SentEmailQueue queue) {
        sentEmailQueueMapper.insert(queue);
    }

    @Override
    public void update(SentEmailQueue queue) {
        sentEmailQueueMapper.update(queue);
    }

    @Override
    public void delete(Integer dataId) {
        sentEmailQueueMapper.delete(dataId);
    }
}



Service
package com.pandy.service;

/**
 * Created by pandy on 14-8-13.
 */
public interface SentEmailQueueService {
    public void test(boolean isRollback);
}


package com.pandy.service.impl;

import com.pandy.dao.SentEmailQueueDao;
import com.pandy.model.SentEmailQueue;
import com.pandy.service.SentEmailQueueService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@Service("sentEmailQueueService")
@Transactional
public class SentEmailQueueServiceImpl implements SentEmailQueueService {

    @Resource(name = "sentEmailQueueDao")
    private SentEmailQueueDao sentEmailQueueDao;


    @Override
    @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = RuntimeException.class)
    public void test(boolean isRollback) {
        Date date = new Date();
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd_HHmmss");
        SentEmailQueue queue = new SentEmailQueue();
        queue.setToEmail(format.format(date) + "@pandy8.com");
        sentEmailQueueDao.insert(queue);


        List<SentEmailQueue> list = sentEmailQueueDao.getAll();
        int update_id = 0;
        for (SentEmailQueue row : list) {
            queue = sentEmailQueueDao.get(row.getDataId());
            System.out.println(queue.toString());
            update_id = row.getDataId();
        }

        date = new Date();
        format = new SimpleDateFormat("yyyyMMdd_HHmmss");
        queue = new SentEmailQueue();
        queue.setDataId(update_id);
        queue.setToEmail("update_" + format.format(date) + "@pandy8.com");
        sentEmailQueueDao.update(queue);

        System.out.println("将被删除的id=" + (update_id - 1));
        sentEmailQueueDao.delete(update_id - 1);

        if(isRollback) {
            throw new RuntimeException("事务测试: 故意抛出异常,使得对数据库的操作失败");
        }
    }

}



Controller
package com.pandy.controller;

import com.pandy.service.SentEmailQueueService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;

/**
 * Created by pandy on 14-8-13.
 */
@Controller
@RequestMapping("/myController")
public class MyController {

    @Resource(name="sentEmailQueueService")
    private SentEmailQueueService sentEmailQueueService;

    @RequestMapping("/test")
    public ModelAndView test(@RequestParam("isRollback") boolean isRollback){
        System.out.println("==================>isRollback="+isRollback);
        sentEmailQueueService.test(isRollback);
        return new ModelAndView("index");
    }
}



访问:
正常事务: http://localhost:8080/SpringMybatis/myController/test.do?isRollback=false
回滚事务: http://localhost:8080/SpringMybatis/myController/test.do?isRollback=true




附加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.pandy</groupId>
    <artifactId>spmybatis</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <properties>
        <buildNumber>1</buildNumber>
        <java.version>1.7</java.version>
        <mybatis.version>3.2.7</mybatis.version>
        <mybatis.spring.version>1.2.2</mybatis.spring.version>
        <mysql.version>5.1.30</mysql.version>
        <spring.version>4.0.5.RELEASE</spring.version>
        <spring.security.version>3.2.4.RELEASE</spring.security.version>
        <spring.asm.version>3.1.4.RELEASE</spring.asm.version>
        <aspectj.version>1.6.2</aspectj.version>

        <mysql.version>5.1.30</mysql.version>
        <jdbc.groupId>com.alibaba</jdbc.groupId>
        <jdbc.artifactId>druid</jdbc.artifactId>
        <jdbc.version>1.0.4</jdbc.version>
    </properties>


    <dependencies>
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
            <version>${mybatis.version}</version>
        </dependency>
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis-spring</artifactId>
            <version>${mybatis.spring.version}</version>
        </dependency>

        <!-- Spring 3 -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-asm</artifactId>
            <version>${spring.asm.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aspects</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-expression</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${spring.version}</version>
        </dependency>


        <!-- Log4j -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.6.1</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.16</version>
            <exclusions>
                <exclusion>
                    <artifactId>log4j</artifactId>
                    <groupId>log4j</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.6.1</version>
        </dependency>
        <dependency>
            <groupId>org.lazyluke</groupId>
            <artifactId>log4jdbc-remix</artifactId>
            <version>0.2.7</version>
        </dependency>


        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>taglibs</groupId>
            <artifactId>standard</artifactId>
            <version>1.1.2</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>15.0</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>${mysql.version}</version>
        </dependency>
        <dependency>
            <groupId>sqljdbc</groupId>
            <artifactId>sqljdbc</artifactId>
            <version>4.0</version>
        </dependency>
        <dependency>
            <groupId>${jdbc.groupId}</groupId>
            <artifactId>${jdbc.artifactId}</artifactId>
            <version>${jdbc.version}</version>
        </dependency>
    </dependencies>


    <build>
        <finalName>SpringMybatis</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.5</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
                <configuration>
                    <archive>
                        <manifest>
                            <!--<addClasspath>true</addClasspath> -->
                        </manifest>
                        <manifestEntries>
                            <Built-By>org-builder</Built-By>
                            <Build-Jdk>${java.version}</Build-Jdk>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <url>http://localhost:8080/manager/text</url>
                    <username>admin</username>
                    <password>admin</password>
                    <path>/SpringMybatis</path>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>maven-jetty-plugin</artifactId>
                <version>6.1.20</version>
                <configuration>
                    <contextPath>/SpringMybatis</contextPath>
                    <!--<webDefaultXml>webdefault.xml</webDefaultXml> -->
                    <scanIntervalSeconds>0</scanIntervalSeconds>
                    <scanTargetPatterns>
                        <scanTargetPattern>
                            <directory>src/main/webapp/WEB-INF</directory>
                            <excludes>
                                <exclude>**/*.jsp</exclude>
                            </excludes>
                            <includes>
                                <include>**/*.properties</include>
                                <include>**/*.xml</include>
                            </includes>
                        </scanTargetPattern>
                    </scanTargetPatterns>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.0.2</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                        <manifestEntries>
                            <Implementation-Build>${buildNumber}</Implementation-Build>
                        </manifestEntries>
                    </archive>
                    <dependentWarExcludes>
                        **/jdbc.properties,**/web.xml,WEB-INF/classes/META-INF/**
                    </dependentWarExcludes>
                </configuration>
            </plugin>
        </plugins>
    </build>


</project>

你可能感兴趣的:(springMVC)