SSM项目配置文件整合

项目结构

SSM项目配置文件整合

jdbc-mysql.properties

建议带上jdbc.

jdbc.url=jdbc:mysql://localhost:3306/hrm?useUnicode=true&characterEncoding=utf8
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.username=root
jdbc.password=root

log4j.properties

log4j.rootLogger=DEBUG, stdout
log4j.logger.org.apache=ERROR
log4j.logger.org.springframework=ERROR
log4j.logger.org.mybatis=DEBUG
log4j.logger.org.apache.http=ERROR
log4j.logger.com.netflix=ERROR
log4j.appender.stdout=org.apache.log4j.ConsoleAppender 
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 
log4j.appender.stdout.layout.ConversionPattern=%5p %d %C: %m%n

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>
    <properties>  
        <property name="dialect" value="mysql" />  
    </properties>
    <settings>
         <setting name="logImpl" value="LOG4J" />
    </settings>
</configuration>

applicationContext.xml

1.需要导入对应头文件
2.扫描service层
3.加载数据库配置信息 一般为properties文件
4.配置数据库连接池,一般为c3p0或者dbcp
5.配置sqlSessionFactory类
6.配置事务管理器(需要一个管理器类和一个上面连接池的引入)
7.把事务管理器增强,就是配置自定义的事务
8.设置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:p="http://www.springframework.org/schema/p"
    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-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">
    <!-- 扫描service层 -->
    <context:component-scan base-package="com.lzh.hrm.service"/>
    <!-- 加载数据库配置信息 -->
    <context:property-placeholder location="classpath:jdbc-mysql.properties"/>
    <!-- 配置数据库连接池dbcp -->
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
        p:url="${jdbc.url}"
        p:driverClassName="${jdbc.driverClassName}"
        p:username="${jdbc.username}"
        p:password="${jdbc.password}"/>
     <!-- 配置sqlSessionFactory类 -->
    <bean id="sqlSessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean"
        p:dataSource-ref="dataSource"
        p:mapperLocations="classpath:mybatis/mapper/*.xml"  //扫描与dao层接口名相同的.xml配置文件,完成依赖,不用写dao实现类
        p:typeAliasesPackage="com.lzh.hrm.entity"          //给实体类起别名。默认的是类的类名小写,在mapper.xml文件可以直接用别名引用,无需在引入全包名。
        p:configLocation="classpath:mybatis/mybatis-config.xml"/>  // mybatis的配置文件设置方言。日志什么的
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"
        p:basePackage="com.lzh.hrm.dao"/>  //扫描这个包下面的dao接口,与xml文件意义对应,注意接口名和xml文件名一定要一样

    <!-- 事务管理器-->
    <bean id="transactionManager" 
        class="org.springframework.jdbc.datasource.DataSourceTransactionManager"
        p:dataSource-ref="dataSource"/>
    <!-- 把事务管理器包装成advice -->

    <tx:advice id="txAdvice"  transaction-manager="transactionManager">
        <tx:attributes>
            <tx:method name="get*" read-only="true"/>
            <tx:method name="save*" propagation="REQUIRED" rollback-for="Exception"/>
            <tx:method name="delete*" propagation="REQUIRED" rollback-for="Exception"/>
            <tx:method name="update*" propagation="REQUIRED" rollback-for="Exception"/>
        </tx:attributes>
    </tx:advice>
    <aop:config>
        <aop:pointcut expression="execution(* com.lzh.hrm.service..*.*(..))" id="businessService"/>
        <aop:advisor advice-ref="txAdvice" pointcut-ref="businessService"/>
    </aop:config>  
</beans>

UserDao.xml配置文件(7个常用方法。)

注意:namespace一定要写dao层的接口全类名

<?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.lzh.hrm.dao.UserDao">
    <sql id="key">
        <trim suffixOverrides=",">
            <if test="loginname!=null">
                loginname,
            </if>
            <if test="password!=null">
                password,
            </if>
            <if test="status!=null">
                status,
            </if>
            <if test="createdate!=null">
                createdate,
            </if>
            <if test="username!=null">
                username,
            </if>
        </trim>
    </sql>
    <sql id="value">
        <trim suffixOverrides=",">
            <if test="loginname!=null">
                #{loginname},
            </if>
            <if test="password!=null">
                #{password},
            </if>
            <if test="status!=null">
                #{status},
            </if>
            <if test="createdate!=null">
                #{createdate},
            </if>
            <if test="username!=null">
                #{username},
            </if>
        </trim>
    </sql>
    <select id="getById" resultType="user">
         select 
            id,
            loginname,
            password,
            status,
            createdate,
            username
        from 
            user_inf
        where
            id=#{id}
    </select>

    <select id="getByloginnameAndPassWord" resultType="user">
        select 
            id,
            loginname,
            password,
            status,
            createdate,
            username
        from 
            user_inf
        where
            loginname=#{loginname}
        and
            password=#{password}
    </select>
    <insert id="save" parameterType="user">

        insert into user_inf(<include refid="key"/>) values(<include refid="value"/>)
    </insert>

    <delete id="delete">
        delete from user_inf where id=#{id}
    </delete>

    <update id="update" parameterType="user">
        update user_inf
            <set>
                <if test="loginname!=null">
                    loginname=#{loginname},
                </if>
                <if test="password!=null">
                    password=#{password},
                </if>
                <if test="status!=null">
                    status=#{status},
                </if>
                <if test="createdate!=null">
                    createdate=#{createdate},
                </if>
                <if test="username!=null">
                    username=#{username},
                </if>
            </set>
            where
                id=#{id}
    </update>

    <select id="getAll" resultType="user">
        select 
            id,
            loginname,
            password,
            status,
            createdate,
            username
        from user_inf
    </select>

     <select id="count"  resultType="int">
        select
            count(id)
        from 
            user_inf
        <where>
            <if test="pid!=null">
                id =#{pid}
            </if>
            <if test="pname!=null">
                and loginname like concat(concat("%",#{pname}),"%")
            </if>
        </where>
    </select>
    <select id="getByPage" resultType="user">
        select 
            id,
            loginname,
            password,
            status,
            createdate,
            username
        from 
            user_inf

        <where>
            <if test="pid!=null">
                and id =#{pid}
            </if>

            <if test="pname!=null">
                and loginname like concat(concat("%",#{pname}),"%")
            </if>

        </where>    
        <if test="start!=null and pageSize!=null">
            limit #{start},#{pageSize}
        </if>
    </select>
</mapper>

docuemnt类的mapper文件

<?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.lzh.hrm.dao.DocumentDao">

    //需要特别注意的是,这里document类是个特别的类,里面包含了user类,所以需要使用resultMap指定一下
    <resultMap type="document" id="documentMap">
        <id column="document_id" property="id"/>
        <result column="document_title" property="title"/>
        <result column="document_filename" property="filename"/>
        <result column="document_remark" property="remark"/>
        <result column="document_createDate" property="createDate"/>
        <association property="user" column="user_id" javaType="user">
            <id column="user_id" property="id"/>
            <result column="user_loginname" property="loginname"/>
        </association>
    </resultMap> 



    <insert id="save" parameterType="document">
        insert into
            document_inf(title,filename,remark,create_date,user_id)
        values
            (#{title},#{filename},#{remark},#{createDate},#{user.id})
    </insert>

     <select id="getById" resultMap="documentMap">
        select 
            d.id document_id,
            d.title document_title,
            d.filename document_filename,
            d.remark document_remark,
            d.create_date document_createDate,
            u.id user_id,
            u.loginname user_loginname
        from 
            document_inf d,user_inf u
        where
            d.user_id = u.id and d.id=#{id}
    </select>


    <update id="update" parameterType="document">
        update 
            document_inf
        <set>
            <if test="title!=null">
                title=#{title},
            </if>
            <if test="filename!=null">
                filename=#{filename},
            </if>
            <if test="remark!=null">
                remark=#{remark},
            </if>
        </set>
        where
            id=#{id}
    </update>


    <delete id="delete">
        delete from
            document_inf
        where
            id=#{id}
    </delete>


    <select id="getByPage" parameterType="map" resultMap="documentMap">
        select 
            d.id document_id,
            d.title document_title,
            d.filename document_filename,
            d.remark document_remark,
            d.create_date document_createDate,
            u.id user_id,
            u.loginname user_loginname
        from
            document_inf d,
            user_inf u
        where 
            d.user_id = u.id
        <if test="pid!=null">
                and d.id =#{pid}
        </if>
        <if test="pname!=null">
                and d.title like concat(concat("%",#{pname}),"%")
        </if>
        <if test="start!=null and pageSize!=null">
            limit #{start},#{pageSize}
        </if>
    </select>

    <select id="count" parameterType="map" resultType="int">
        select
            count(id)
        from 
            document_inf
        <where>
            <if test="pid!=null">
                id =#{pid}
            </if>
            <if test="pname!=null">
                and title like concat(concat("%",#{pname}),"%")
            </if>
        </where>
    </select>



</mapper>

spring-mvc.xml

1.扫描 controller层
2.启用默认的配置
3.视图解析
4.权限检查拦截器
5.上传文件

<?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:p="http://www.springframework.org/schema/p"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
        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-4.0.xsd">
    <!-- 扫描controller层 -->
    <context:component-scan base-package="com.lzh.hrm.controller"/>
    <!-- 启用默认配置 -->
     <!--打开注解扫描器-->
    <mvc:annotation-driven >
        <!--json转换器-->
        <mvc:message-converters>
            <bean id="fastjson" class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">

                <property name="supportedMediaTypes">
                    <list>
                        <value>text/html;charset=UTF-8</value>
                        <value>application/json;charset=UTF-8</value>
                    </list>
                </property>
            </bean>
        </mvc:message-converters>
    </mvc:annotation-driven>
    <mvc:default-servlet-handler/>
    <!-- 视图解析 -->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"
        p:prefix="/WEB-INF/jsp/"
        p:suffix=".jsp"/>

    <!-- 权限检查拦截器 -->
    <mvc:interceptors>
        <mvc:interceptor>
            <mvc:mapping path="/**"/>     //拦截所有请求
            <bean class="com.shaokp.hrm.interceptor.AuthorizedInterceptor"/> //自定义拦截器的类
        </mvc:interceptor>
    </mvc:interceptors>
    <!-- 上传文件设置 -->
    <!-- 上传文件设置 -->
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"
        p:maxUploadSize="10485760"
        p:defaultEncoding="UTF-8"/>
</beans>

controller层上传文件

注意:前台form表单需要加enctype=”multipart/form-data”属性,数据用FormData类包装,ajax的那几个属性一定得带上

jsp代码

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<form id="addDocForm"  method="post" enctype="multipart/form-data">
    <table style="width:400px;margin:0 auto;margin-top:50px;"> 
        <tr>
            <td style="width:100px;text-align:right;padding-right:30px"><label for="title">标题:</label></td>
            <td>
                <input id="title"  type="text" name="title"  />
            </td>
        </tr>  
        <tr>
            <td colspan="2"><br/></td>
        </tr>

        <tr>
            <td style="width:100px;text-align:right;padding-right:30px"><label for="remark">标记</label></td>
            <td>
                <input id="remark"  type="text" name="remark"  />
            </td>
        </tr>
        <tr>
            <td colspan="2"><br/></td>
        </tr>
        <tr>
            <td style="width:100px;text-align:right;padding-right:30px" ><label for="s-file">文件:</label></td>
            <td>
                <input id="file" id="s-file" type="file" name="file" />
            </td>
        </tr> 

        <tr>
            <td colspan="2"><br/></td>
        </tr> 
        <tr>
            <td style="width:100px;text-align:right;padding-right:30px"></td>
            <td>
                <a id="btn" href="javascript:void(0)" onclick="saveAdd()" class="easyui-linkbutton" data-options="">提交</a>  
                <a id="btn" href="javascript:void(0)" onclick="cancelAdd()" class="easyui-linkbutton" data-options="">取消</a>  
            </td>
        </tr>
    </table>   
</form>
<script>
    function saveAdd(){
         var formData = new FormData($( "#addDocForm" )[0]);
         $.ajax({  
              url: './doc/saveDoc' , 
              type: 'POST',  
              data: formData, 
              cache: false,  
              contentType: false,  
              processData: false,  
              success: function (data) { 
                console.log(data);
                    if(data=="ok"){
                        $('#win-addDoc').window('close');
                        $('#dg-docList').datagrid('reload');
                    }
              } 
         }); 
    }
    function cancelAdd(){
        $('#win-addDoc').window('close');
    }
</script>
@RequestMapping("/doc/saveDoc")
    @ResponseBody
    public String saveDept(Document doc,HttpSession session)throws Exception{
        //获取上传文件路径
        String path = session.getServletContext().getRealPath("/").replace("\\hrm-lzh", "");
        System.out.println(path);
        path+="hrm-upload";
        System.out.println(path);
        User user = (User)session.getAttribute("user");
        //获取上传文件名称 --存储时使用uuid作为文件名的前缀
        //使用uuid文件名
        String uuid  = UUID.randomUUID().toString();
        uuid=uuid.replace("-", "");
        System.out.println(doc);
        String filename =uuid+"date_"+doc.getFile().getOriginalFilename();
        System.out.println(filename);
        //将上传的文件保存到文件夹中
        File dir=new File(path);
        if(!dir.exists()){
            dir.mkdirs();
        }
        System.out.println(path+File.separator+filename);
        doc.getFile().transferTo(new File(path+File.separator+filename));
        //把文档信息插入数据库
        doc.setFilename(filename);
        doc.setUser(user);
        hrmService.addDocument(doc);
        return "ok";
    }

下载文件

根据id来得到doc类,注意前台要用超链接的方式访问,不能用ajax来访问!!!!

@RequestMapping("/doc/download")
    public ResponseEntity<byte[]>  download(Integer id,HttpSession session,HttpServletResponse response) throws Exception{
        Document doc = hrmService.findDocumentById(id);
        String path = session.getServletContext().getRealPath("/").replace("\\hrm-lzh", "");
        path+="hrm-upload"; 
        File file = new File(path+File.separator+doc.getFilename());
        HttpHeaders headers = new HttpHeaders();
        String downloadFilename = new String(doc.getFilename().getBytes("utf-8"),"iso-8859-1");
        downloadFilename=downloadFilename.substring(37);
        headers.setContentDispositionFormData("attachment", downloadFilename);
        headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
        return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),headers,HttpStatus.CREATED);
    }

spring-mvc的拦截器

package com.shaokp.hrm.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import com.shaokp.hrm.entity.User;

public class AuthorizedInterceptor implements HandlerInterceptor{

    private static final String[] LOGIN_URI={"/login","/loginCheck","404.html"};

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
            throws Exception {
        boolean flag=false;
        String servletPath = request.getServletPath();
        for(String path:LOGIN_URI){
            if(servletPath.contains(path)){
                flag=true;
                break;
            }
        }
        if(!flag){
            User user = (User)request.getSession().getAttribute("user");
            if(user==null){
                request.setAttribute("message", "请先登录再访问网站");
                request.getRequestDispatcher("/login").forward(request,response);
            }
        }else{
            flag=true;
        }
        return flag;
    }

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
            ModelAndView modelAndView) throws Exception {

    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
            throws Exception {

    }

}

web.xml文件

1.配置spring配置文件所在位置
2.配置spring容器监听器
3.配置springmvc核心控制器
4.设置编码过滤器
5.设置自定义过滤器(可选)
6.配置WEB-INF下的jsp访问(可选)

<?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">
    <!-- spring配置文件所在位置 -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:spring/applicationContext.xml</param-value>
    </context-param>
    <!-- spring容器 -->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <!-- springmvc核心控制器 -->
    <servlet>
        <servlet-name>hrm</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:spring/spring-mvc.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>hrm</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
    <!-- 编码过滤器 -->
    <filter>
        <filter-name>characterEncoding</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>characterEncoding</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <!-- 设置自定义过滤器 -->
    <filter>
        <filter-name>myfilter</filter-name>
        <filter-class>com.lzh.hrm.util.MyFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>myfilter</filter-name>
        <url-pattern>*.jsp</url-pattern>
        <url-pattern>*.action</url-pattern>
    </filter-mapping>
    <welcome-file-list>
        <welcome-file>/login.jsp</welcome-file>
    </welcome-file-list>
    <error-page>
        <error-code>404</error-code>
        <location>/404.html</location>
    </error-page>

    <!-- 配置WEB-INF下的jsp访问 -->
    <servlet>
        <servlet-name>head</servlet-name>
        <jsp-file>/WEB-INF/jsp/head.jsp</jsp-file>
    </servlet>
    <servlet-mapping>
        <servlet-name>head</servlet-name>
        <url-pattern>/user/head.jsp</url-pattern>
    </servlet-mapping>
    <servlet>
        <servlet-name>tab</servlet-name>
        <jsp-file>/WEB-INF/jsp/tabs.jsp</jsp-file>
    </servlet>
    <servlet-mapping>
        <servlet-name>tab</servlet-name>
        <url-pattern>/user/tabs.jsp</url-pattern>
    </servlet-mapping>
    <!-- 这个的意思是下面的文件路径交给tomcat来处理,默认的名字就是default,因为mvc的拦截器要拦截所有的请求,所以这些请求要交给默认的处理类,配置一下不要拦截 ,这个配合这spring-mvc的配置文件有个开启默认配置-->
    <servlet-mapping>
        <servlet-name>default</servlet-name>
        <url-pattern>*.css</url-pattern>
        <url-pattern>*.js</url-pattern>
        <url-pattern>*.html</url-pattern>
        <url-pattern>*.jpg</url-pattern>
    </servlet-mapping>
    //配置jsp默认配置
    <jsp-config>
        <jsp-property-group>
            <!-- 配置拦截所有的jsp页面 -->
            <url-pattern>*.jsp</url-pattern>
            <!-- 可以使用el表达式 -->
            <el-ignored>false</el-ignored>
            <!-- 不能在页面使用java脚本 -->
            <scripting-invalid>true</scripting-invalid>
            <!-- 给所有的jsp页面导入要依赖的库,tablib.jsp就是一个全局的标签库文件 -->
            <include-prelude>/WEB-INF/jsp/taglib.jsp</include-prelude>

        </jsp-property-group>
    </jsp-config>
 </web-app>

pom.xml文件

<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.lzh</groupId>
  <artifactId>hrm</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>


    <properties>
        <!-- spring版本号 -->
        <spring.version>4.0.2.RELEASE</spring.version>
        <!-- mybatis版本号 -->
        <mybatis.version>3.2.6</mybatis.version>
        <!-- log4j日志文件管理包版本 -->
        <slf4j.version>1.7.7</slf4j.version>
        <log4j.version>1.2.17</log4j.version>
    </properties>


    <dependencies>
        <dependency>
            <groupId>net.sf.json-lib</groupId>
            <artifactId>json-lib</artifactId>
            <version>2.1</version>

        </dependency>

        <!-- 导入dbcp的jar包,用来在applicationContext.xml中配置数据库 -->
        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>1.2.2</version>
        </dependency>
        <!-- spring核心包 -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</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-orm</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-jdbc</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-aop</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-test</artifactId>
            <version>${spring.version}</version>
            <scope>test</scope>
        </dependency>
        <!-- 导入mybatis包 -->
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
            <version>3.2.6</version>
        </dependency>
        <!-- mybatis/spring包 -->
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis-spring</artifactId>
            <version>1.2.2</version>
        </dependency>
        <!-- 上传文件 -->
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.4</version>
        </dependency>
        <!-- 使用junit进行单元测试 -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
        <!-- 导入Mysql数据库链接jar包 -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.30</version>
        </dependency>
        <!-- json数据 -->
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-core-asl</artifactId>
            <version>1.9.13</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>1.9.13</version>
        </dependency>
        <!-- JSTL标签类 -->
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
        <groupId>taglibs</groupId>
        <artifactId>standard</artifactId>
        <version>1.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 -->
        <!--使用AspectJ方式注解需要相应的包 -->
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>1.6.11</version>
        </dependency>
        <!--使用AspectJ方式注解需要相应的包 -->
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
            <version>1.6.11</version>
        </dependency>
        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib</artifactId>
            <version>2.2</version>
        </dependency>
    </dependencies>

    <build>
        <finalName>hrm</finalName>
        <plugins>
            <!-- 编译的时候使用JDK7和UTF8编码 , -->
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <!-- <version>3.0</version> -->
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>

            <!-- 编译jar包 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <addMavenDescriptor>false</addMavenDescriptor>
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                            <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
上一篇:Mysql获取系统时间,年,月,日


下一篇:计算年龄:sql计算