maven项目,struts2+spring+mybatis框架搭建整合,tomcat部署,开发工具Idea

第一步:新建项目,maven项目

一.新建maven项目


1,选择maven

2,选择project sdk 安装的是1.7版的jdk,如果是第一次安装idea 需要配置本地jdk

3,可以选择生成相应的项目结构,本次不作选择,直接下一步


maven项目必须填写GroupId 和ArtifactId,填写后直接下一步

1.填写项目名称 填写完成后点击完成

2.项目名称,目录地址


1.新建项目的目录结构

2.maven的pom文件,文件名称是项目名称,

3.groupId和artifactId ,这两个id命名通常是不同的有一定规则,这里为了方便,简单命名


1.maven project 可以看到有关maven 的功能项

2lifecyle 点击clean会将项目解除依赖 ,install会添加依赖

3.maven项目如果出现jar包更新,运行,必须进行点击clean,重新install。


二.配置tomcat



进入到配置界面

1.点击加号添加tomcat server 如果没有tomcat 选项要在idea中安装tomcat插件具体在seting中。

2.选择local 


1.填写名字

2.点击下拉框选择本地tomcat目录进行配置

3.部署


点击artifact进行部署,这里部署方式是将war包进行发布,如果新建项目没有war包可以点击右下方Fix进行生成,本次是使用maven进行打war包,具体在pom文件中进行配置。



war包发布后 点击Server,可以进行相关配置





至此新建maven项目完毕,剩下就应该是整合框架。

第二步:搭建Spring

1.加入jar包,在pom文件中写入spring所用jar包



[html]  view plain  copy
  1. <!--spring核心包-->  
  2.         <dependency>  
  3.             <groupId>org.springframework</groupId>  
  4.             <artifactId>spring-core</artifactId>  
  5.             <version>3.2.3.RELEASE</version>  
  6.         </dependency>  
  7.         <dependency>  
  8.             <groupId>org.springframework</groupId>  
  9.             <artifactId>spring-beans</artifactId>  
  10.             <version>3.2.3.RELEASE</version>  
  11.         </dependency>  
  12.         <dependency>  
  13.             <groupId>org.springframework</groupId>  
  14.             <artifactId>spring-web</artifactId>  
  15.             <version>3.2.3.RELEASE</version>  
  16.         </dependency>  
  17.         <dependency>  
  18.             <groupId>org.springframework</groupId>  
  19.             <artifactId>spring-context</artifactId>  
  20.             <version>3.2.3.RELEASE</version>  
  21.         </dependency>  
  22.         <dependency>  
  23.             <groupId>org.springframework</groupId>  
  24.             <artifactId>spring-jdbc</artifactId>  
  25.             <version>3.2.3.RELEASE</version>  
  26.         </dependency>  
  27.         <dependency>  
  28.             <groupId>org.springframework</groupId>  
  29.             <artifactId>spring-webmvc</artifactId>  
  30.             <version>3.2.3.RELEASE</version>  
  31.         </dependency>  
  32.         <dependency>  
  33.             <groupId>org.springframework</groupId>  
  34.             <artifactId>spring-webmvc-portlet</artifactId>  
  35.             <version>3.2.3.RELEASE</version>  
  36.         </dependency>  

2.创建spring配置文件

1.在项目目录中创建spring.xml配置文件,idea工具可以自动生成配置文件,在项目根目录上右键添加框架支持。

2.初始spring配置文件,只要写入自动扫描包即可,在项目启动时spring会自动去扫描。

3.本项目采用注解方式,不再配置文件中在写相关配置。


[html]  view plain  copy
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"  
  4.        xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"  
  5.        xsi:schemaLocation="  
  6.             http://www.springframework.org/schema/beans  
  7.             http://www.springframework.org/schema/beans/spring-beans.xsd  
  8.             http://www.springframework.org/schema/context  
  9.             http://www.springframework.org/schema/context/spring-context.xsd  
  10.             http://www.springframework.org/schema/aop  
  11.             http://www.springframework.org/schema/aop/spring-aop.xsd  
  12.             http://www.springframework.org/schema/tx  
  13.             http://www.springframework.org/schema/tx/spring-tx.xsd">  
  14. <!--自动扫描包-->  
  15.     <context:component-scan base-package="com.ztx"></context:component-scan>  
  16.   
  17. </beans>  

三.测试spring

1.在service层创建接口,在impl文件夹中写实现类



1.编写service层和service实现类

2.注解方式,在spring启动的时会根据这个注解将它加入到上下文中,相当于在spring配置文件中加<bean id = calss =></bean>




因为在spring配置文件中写了自动扫描包,只要service文件能被扫描到就可以。

1.在test文件目录下建测试文件。

2.获取spring上下文

3.JUnit测试方法,不需要写main方法。


四.spring配置web.xml

要让spring在web项目中应用,所以要在web.xml文件中配置。

1.指定spring配置文件的位置

2.指定一个监听器,只有指定了监听器,才能在web项目启动中把spring上下文启动。



第三步:搭建struts2

一.加入jar包

1.在pom文件中加入struts2核心包,struts2的注解包,因为要和spring做整合,所以要加入struts2-spring-plugin。

2.idea中如果有个功能未自动导入jar包,就是在pom文件中写完jar包后会自动导入,右下方eventlog

3.点击enable,就可以自动导入jar包了




二.创建配置文件

1.创建config目录,struts配置文件struts.xml,

2.web目录,web.xml文件




struts2基础配置文件struts.xml基本配置

[html]  view plain  copy
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <!DOCTYPE struts PUBLIC  
  3.         "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"  
  4.         "http://struts.apache.org/dtds/struts-2.0.dtd">  
  5. <struts>  
  6.     <!-- 指定由spring负责action对象的创建 -->  
  7.     <constant name="struts.objectFactory" value="spring"></constant>  
  8.     <!-- 所有匹配*。action的请求都有struts2处理 -->  
  9.     <constant name="struts.action.extension" value="action,do,"></constant>  
  10.     <!-- 是否应用开发模式 -->  
  11.     <constant name="struts.devMode" value="true"></constant>  
  12.     <!-- struts配置文件改动后是否重新加载,2.3.14之前的版本有效 -->  
  13.     <constant name="struts.configuration.xml.reload" value="true"></constant>  
  14.     <!-- 设置浏览器是否缓存静态内容,生产环境中可设置为true -->  
  15.     <constant name="struts.serve.static.browserCache" value="false"></constant>  
  16.     <!-- 请求参数的编码方式 -->  
  17.     <constant name="struts.i18n.encoding" value="UTF-8"></constant>  
  18.     <!-- 每次HTTP请求都重新加载系统资源,有助于开发-->  
  19.     <constant name="struts.i18n.reload" value="true"></constant>  
  20.     <!-- 文件上传最大值 -->  
  21.     <constant name="struts.multipart.maxSize" value="104857600"></constant>  
  22.     <!-- 让struts2支持动态方法调用 -->  
  23.     <constant name="struts.enable.DynamicMethodInvocation" value="true"></constant>  
  24.     <!-- action名称中是否还是用斜线-->  
  25.     <constant name="struts.enable.SlashesInActionNames" value="false"></constant>  
  26.     <!-- 允许标签中使用表达式语法-->  
  27.     <constant name="struts.tag.Syntax" value="true"></constant>  
  28.     <!-- 对于WebLogic,Orion,OC4J此属性设置为true-->  
  29.     <constant name="struts.dispather.parametersWorkaroud" value="false"></constant>  
  30.   
  31.     <package name="basePackage-struts" extends="struts-default">  
  32.   
  33.     </package>  
  34.   
  35. </struts>  

三.sturts配置web.xml文件




四.编写测试类进行测试,项目目录

因为struts2-spring-plugin 包spring就会自动找@Action将它加入spring进行管理


在浏览器中输入 http://localhost:8081/userAction!test.action 因为部署时没有写项目名称所以地址不用写项目名称

第四步:搭建mybatis

一.加入mybatis 的jar包,和mybatis和spring整合jar包


二.创建mybatis的配置文件,



[html]  view plain  copy
  1. <?xml version="1.0" encoding="UTF-8" ?>  
  2. <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"  
  3. "http://mybatis.org/dtd/mybatis-3-config.dtd">  
  4. <!--  didn't use -->  
  5. <configuration>  
  6.     <!-- MyBatis 按照如下的顺序加载它们 1.在 properties 元素体内指定的属性首先被读取。 2.从类路径下资源或 properties   
  7.         元素的 url 属性中加载的属性第二被读取,它会 覆盖已经存在的完全一样的属性。 3.作为方法参数传递的属性最后被读取,它也会覆盖任一已经存在的完全一样的   
  8.         属性,这些属性可能是从 properties 元素体内和资源/url 属性中加载的。 -->  
  9.     <!-- <properties resource="com/bupt/mybatis/config.properties">  
  10.         <property name="username" value="root" />  
  11.         <property name="password" value="yang1290" />  
  12.     </properties> -->  
  13.   
  14.     <settings>  
  15.         <!-- 这个配置使全局的映射器启用或禁用缓存。|true,false|true -->  
  16.         <setting name="cacheEnabled" value="true" />  
  17.         <!-- 全局启用或禁用延迟加载。当禁用时,所有关联对象都会即时加载。|true,false|true -->  
  18.         <setting name="lazyLoadingEnabled" value="true" />  
  19.         <!-- 当启用时,有延迟加载属性的对象在被调用时将会完全加载任意属性。否则, 每种属性将会按需要加载。|true,false|true -->  
  20.         <setting name="aggressiveLazyLoading" value="true" />  
  21.         <!-- 允许或不允许多种结果集从一个单独 的语句中返回(需要适合的驱动)。|true,false|true -->  
  22.         <setting name="multipleResultSetsEnabled" value="true" />  
  23.         <!-- 使用列标签代替列名。不同的驱动在这 方便表现不同。参考驱动文档或充分测试两种方法来决定所使用的驱动。|true,false|true -->  
  24.         <setting name="useColumnLabel" value="true" />  
  25.         <!-- 允许 JDBC 支持生成的键。需要适合的驱动。如果设置为 true 则这个设置强制生成的键被使用,尽管一些驱动拒绝兼容但仍然有效(比如   
  26.             Derby)。|true,false|false -->  
  27.         <setting name="useGeneratedKeys" value="false" />  
  28.         <!-- 指定 MyBatis 如何自动映射列到字段/属性。PARTIAL只会自动映射简单, 没有嵌套的结果。FULL会自动映射任意复杂的结果(嵌套的或其他情况)。|NONE,   
  29.             PARTIAL, FULL| PARTIAL -->  
  30.         <setting name="autoMappingBehavior" value="PARTIAL" />  
  31.         <!-- 配置默认的执行器。SIMPLE 执行器没 有什么特别之处。REUSE 执行器重用 预处理语句。BATCH 执行器重用语句和批量更新   
  32.             |SIMPLE, REUSE, BATCH|SIMPLE -->  
  33.         <setting name="defaultExecutorType" value="SIMPLE" />  
  34.         <!-- 设置超时时间,它决定驱动等待一个数据库响应的时间。| Any positive integer |Not Set (null) -->  
  35.         <setting name="defaultStatementTimeout" value="25000" />  
  36.         <!--   设置但JDBC类型为空时,某些驱动程序 要指定值,default:OTHER-->    
  37.         <setting name="jdbcTypeForNull" value="NULL"/>   
  38.         <!-- <setting name="logImpl" value="LOG4J" />  -->  
  39.     </settings>  
  40.   
  41.     <!-- 类型别名是为 Java 类型命名一个短的名字。它只和 XML 配置有关,只用来减少类完全 限定名的多余部分。 -->  
  42.     <typeAliases>  
  43.         <typeAlias alias="User" type="com.ztx.entity.User" />  
  44.     </typeAliases>  
  45.   
  46. <!--   
  47.     <environments default="development">  
  48.         <environment id="development">  
  49.             <transactionManager type="JDBC" />  
  50.             <dataSource type="POOLED">  
  51.                 <property name="driver" value="${driver}" />  
  52.                 <property name="url" value="${url}" />  
  53.                 <property name="username" value="${username}" />  
  54.                 <property name="password" value="${password}" />  
  55.             </dataSource>  
  56.         </environment>  
  57.     </environments>  
  58.    
  59.     <mappers>  
  60.         <mapper resource="com/bupt/mybatis/Test.xml"/>  
  61.     </mappers>-->  
  62.   
  63. </configuration>  

在spring中配置数据库连接池采用的是druid,数据库为oracle。

添加jar包

三.配置datasource

在spring中配置连接池。这里另外建立了一个spring-dataSource文件,在spring-config文件中加载这个文件即可,durid配置连接池为固定格式。将jdbc文件放在指定目录下载spring-datasource文件中指定即可


四.配置事物

五.配置oap切面


spring-datasource文件

[html]  view plain  copy
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"  
  4.     xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"  
  5.     xsi:schemaLocation="  
  6.             http://www.springframework.org/schema/beans  
  7.             http://www.springframework.org/schema/beans/spring-beans.xsd  
  8.             http://www.springframework.org/schema/context  
  9.             http://www.springframework.org/schema/context/spring-context.xsd  
  10.             http://www.springframework.org/schema/aop  
  11.             http://www.springframework.org/schema/aop/spring-aop.xsd  
  12.             http://www.springframework.org/schema/tx  
  13.             http://www.springframework.org/schema/tx/spring-tx.xsd">  
  14.     <!-- <context:property-placeholder location="classpath:config/config.properties"   
  15.         /> <context:component-scan base-package="com.jqy.dao,com.jqy.service"></context:component-scan> -->  
  16.     <!-- 配置连接参数 -->  
  17.     <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">  
  18.         <property name="location" value="classpath:com/ztx/config/jdbc.properties"></property>  
  19.     </bean>  
  20.     <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"  
  21.         init-method="init" destroy-method="close">  
  22.         <property name="driverClassName" value="${driver}"></property>  
  23.         <property name="url" value="${url}"></property>  
  24.         <property name="username" value="${username}"></property>  
  25.         <property name="password" value="${password}"></property>  
  26.         <!-- 初始化链接大小 -->  
  27.         <property name="initialSize" value="0"></property>  
  28.         <!-- 连接池最大使用链接数量 -->  
  29.         <property name="maxActive" value="20"></property>  
  30.         <!-- 连接池最小空闲数量 -->  
  31.         <property name="minIdle" value="0"></property>  
  32.     </bean>  
  33.   
  34.     <!-- 数据源定义,使用 C3P0 连接池 -->  
  35.     <!-- <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"   
  36.         destroy-method="close"> <property name="driverClass" value="${driver}" />   
  37.         <property name="jdbcUrl" value="${url}" /> <property name="user" value="${username}"   
  38.         /> <property name="password" value="${password}" /> <property name="automaticTestTable"   
  39.         value="test_c3p0" /> -->  
  40.     <!--连接池中保留的最大连接数。Default: 15 -->  
  41.     <!-- <property name="maxPoolSize" value="10" /> -->  
  42.     <!--连接池中保留的最小连接数。 -->  
  43.     <!-- <property name="minPoolSize" value="2" /> -->  
  44.     <!--初始化时获取的连接数,取值应在minPoolSize与maxPoolSize之间。Default: 3 -->  
  45.     <!-- <property name="initialPoolSize" value="2" /> -->  
  46.     <!--最大空闲时间,60秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 -->  
  47.     <!-- <property name="maxIdleTime" value="60" /> -->  
  48.     <!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 -->  
  49.     <!-- <property name="acquireIncrement" value="2" /> </bean> -->  
  50.   
  51.     <!--====事务相关控制==-->   
  52.     <bean id="transactionManager"   
  53.         class="org.springframework.jdbc.datasource.DataSourceTransactionManager">   
  54.         <property name="dataSource" ref="dataSource" />   
  55.     </bean>   
  56.     <tx:advice id="userTxAdvice" transaction-manager="transactionManager">   
  57.         <tx:attributes>   
  58.         <!-- 没有配置只读 -->  
  59.             <tx:method name="find*"   propagation="SUPPORTS" read-only="true"/>  
  60.              <tx:method name="get*"    propagation="SUPPORTS" read-only="true"/>  
  61.              <tx:method name="query*"  propagation="SUPPORTS" read-only="true"/>  
  62.              <tx:method name="select*" propagation="SUPPORTS" read-only="true"/>  
  63.             <tx:method name="*" propagation="REQUIRED" rollback-for="java.lang.Exception"/>  
  64.         </tx:attributes>   
  65.     </tx:advice>   
  66.     <aop:config>   
  67.         <aop:pointcut id="pc"   
  68.             expression="execution(* com.ztx.service..*.*(..))" />   
  69.              <!-- 把事务控制在Business层 -->   
  70.         <aop:advisor pointcut-ref="pc" advice-ref="userTxAdvice" />   
  71.     </aop:config>   
  72. </beans>  

在spring-config.xml文件中引入 spring-datasource.xml文件

六.配置sqlSessionFactory


七.jdbc配置文件


8.目录结构

建立dao层和Mapper层目录结构,mybatis有很多方式实现mapper和dao层对应,这里采用在Mapper中配置命名空间


9.UserDao.java

[html]  view plain  copy
  1. package com.ztx.dao;  
  2.   
  3. import com.ztx.entity.User;  
  4.   
  5. /**  
  6.  * Created by Think on 2016/10/19.  
  7.  */  
  8. public interface UserDao {  
  9.   
  10.      User selectById(String id);  
  11. }  

10.UserMapper.xml

[html]  view plain  copy
  1. <?xml version="1.0" encoding="UTF-8" ?>  
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >  
  3. <mapper namespace="com.ztx.dao.UserDao"><!--这个namespace如果不加对应的dao就找不到对应的mapper-->  
  4.     <!--可以自己定义resultMap 数据库中的列名 对象对应的属性-->  
  5.     <resultMap type="User" id="tUser">  
  6.         <id column="id" property="id" />  
  7.         <result column="name" property="name"/>  
  8.         <result column="pwd" property="pwd" />  
  9.     </resultMap>  
  10.   
  11.     <!--resultType是个对象,因为在mybatisConfig.xml中配置过了typeAliases,所以直接写User  
  12.     就可以了,否则要写com.ztx.entity.User-->  
  13.     <select id = "selectById" resultType="User" parameterType="java.lang.String">  
  14.         select * from TUSER t where t.name = #{id}  
  15.     </select>  
  16. </mapper>  

11.在spring-config.xml中配置Dao

每添加一个dao,就要在spring-config中配置


第五步:项目整体

目录结构


1.userAction.java

[java]  view plain  copy
  1. package com.ztx.action;  
  2.   
  3. import com.ztx.entity.User;  
  4. import com.ztx.service.UserService;  
  5. import org.apache.struts2.convention.annotation.Action;  
  6. import org.apache.struts2.convention.annotation.Namespace;  
  7. import org.apache.struts2.convention.annotation.ParentPackage;  
  8.   
  9. import javax.annotation.Resource;  
  10.   
  11. @ParentPackage("struts-default")  
  12. @Namespace("/"//命名空间为根目录  
  13. @Action(value = "userAction")  
  14. public class userAction {  
  15.   
  16.     @Resource(name = "userService")  
  17.     private UserService userService;  
  18.   
  19.     public void test(){  
  20.         System.out.println("进入了Action");  
  21.         String id = "盖伦";  
  22.         User u = userService.SelestPwdById(id);  
  23.         System.out.println("pwd:"+u.getPwd());  
  24.     }  
  25.   
  26. }  

2.UserService.java

[java]  view plain  copy
  1. package com.ztx.service;  
  2.   
  3. import com.ztx.entity.User;  
  4.   
  5. /** 
  6.  * Created by Think on 2017/1/22. 
  7.  */  
  8. public interface UserService {  
  9.   
  10.     public void test();  
  11.   
  12.     public User SelestPwdById(String id);  
  13. }  

3.UserServiceImpl.java

[java]  view plain  copy
  1. package com.ztx.service.impl;  
  2.   
  3. import com.ztx.dao.UserDao;  
  4. import com.ztx.entity.User;  
  5. import com.ztx.service.UserService;  
  6. import org.springframework.stereotype.Service;  
  7.   
  8. import javax.annotation.Resource;  
  9.   
  10. @Service(value = "userService")  
  11. public class UserServiceImpl implements UserService {  
  12.   
  13.     @Resource(name="userDao")  
  14.     private UserDao userDao;  
  15.   
  16.     @Override  
  17.     public void test() {  
  18.         System.out.println("测试spring");  
  19.   
  20.     }  
  21.   
  22.     @Override  
  23.     public User SelestPwdById(String id) {  
  24.         return userDao.selectById(id);  
  25.     }  
  26. }  

4.UserDao.java

[java]  view plain  copy
  1. package com.ztx.dao;  
  2.   
  3. import com.ztx.entity.User;  
  4.   
  5. /** 
  6.  * Created by Think on 2016/10/19. 
  7.  */  
  8. public interface UserDao {  
  9.   
  10.      User selectById(String id);  
  11. }  

5.实体类User.java

[html]  view plain  copy
  1. package com.ztx.entity;  
  2.   
  3. import java.util.Date;  
  4.   
  5. public class User {  
  6.     private  String  id;  
  7.     private  String  name;  
  8.     private  String  pwd;  
  9.     private  Date    createDateName;  
  10.     private  Date    modifyDateTime;  
  11.   
  12.     public String getId() {  
  13.         return id;  
  14.     }  
  15.   
  16.     public void setId(String id) {  
  17.         this.id = id;  
  18.     }  
  19.   
  20.     public String getName() {  
  21.         return name;  
  22.     }  
  23.   
  24.     public void setName(String name) {  
  25.         this.name = name;  
  26.     }  
  27.   
  28.     public String getPwd() {  
  29.         return pwd;  
  30.     }  
  31.   
  32.     public void setPwd(String pwd) {  
  33.         this.pwd = pwd;  
  34.     }  
  35.   
  36.     public Date getCreateDateName() {  
  37.         return createDateName;  
  38.     }  
  39.   
  40.     public void setCreateDateName(Date createDateName) {  
  41.         this.createDateName = createDateName;  
  42.     }  
  43.   
  44.     public Date getModifyDateTime() {  
  45.         return modifyDateTime;  
  46.     }  
  47.   
  48.     public void setModifyDateTime(Date modifyDateTime) {  
  49.         this.modifyDateTime = modifyDateTime;  
  50.     }  
  51. }  



6.UserMapper.xml

[html]  view plain  copy
  1. <?xml version="1.0" encoding="UTF-8" ?>  
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >  
  3. <mapper namespace="com.ztx.dao.UserDao"><!--这个namespace如果不加对应的dao就找不到对应的mapper-->  
  4.     <!--可以自己定义resultMap 数据库中的列名 对象对应的属性-->  
  5.     <resultMap type="User" id="tUser">  
  6.         <id column="id" property="id" />  
  7.         <result column="name" property="name"/>  
  8.         <result column="pwd" property="pwd" />  
  9.     </resultMap>  
  10.   
  11.     <!--resultType是个对象,因为在mybatisConfig.xml中配置过了typeAliases,所以直接写User  
  12.     就可以了,否则要写com.ztx.entity.User-->  
  13.     <select id = "selectById" resultType="User" parameterType="java.lang.String">  
  14.         select * from TUSER t where t.name = #{id}  
  15.     </select>  
  16. </mapper>  
TsetSpring.java

[java]  view plain  copy
  1. /* 
  2. import com.ztx.service.UserService; 
  3. import org.junit.Test; 
  4. import org.springframework.context.ApplicationContext; 
  5. import org.springframework.context.support.ClassPathXmlApplicationContext; 
  6.  
  7.  
  8. public class TestSpring { 
  9.  
  10.     @Test 
  11.     public void test(){ 
  12.         //获得这个spring-config。 
  13.         ApplicationContext ac = new ClassPathXmlApplicationContext 
  14.                 (new String[]{"classpath:\\com\\ztx\\config\\spring\\spring-config.xml"}); 
  15.         UserService userService= (UserService) ac.getBean("userService");   //调用bean 强转 
  16.         userService.test(); 
  17.     } 
  18.  
  19. } 
  20. */  


配置文件

7.spring-config.xml

[html]  view plain  copy
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"  
  4.        xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"  
  5.        xsi:schemaLocation="  
  6.             http://www.springframework.org/schema/beans  
  7.             http://www.springframework.org/schema/beans/spring-beans.xsd  
  8.             http://www.springframework.org/schema/context  
  9.             http://www.springframework.org/schema/context/spring-context.xsd  
  10.             http://www.springframework.org/schema/aop  
  11.             http://www.springframework.org/schema/aop/spring-aop.xsd  
  12.             http://www.springframework.org/schema/tx  
  13.             http://www.springframework.org/schema/tx/spring-tx.xsd">  
  14.     <import resource="classpath:com/ztx/config/spring/spring-dataSource.xml"/>  
  15. <!--自动扫描包-->  
  16.     <context:component-scan base-package="com.ztx"></context:component-scan>  
  17.     <!-- MyBatis sqlSessionFactory 配置 mybatis-->  
  18.     <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">  
  19.         <property name="dataSource" ref="dataSource" />  
  20. <!--  
  21.     该属性用来指定MyBatis的XML配置文件路径,跟Spring整合时,编写MyBatis映射文件的目的无非是配置一下typeAlias、setting之类的  
  22.     元素。不用在其中指定数据源,或者事务处理方式。就算配置了也会被忽略。因为这些都是使用Spring中的配置  
  23.     。当然如果你不打算添加typeAlias 之类的设置的话,你连MyBatis的配置文件都不用写,更不用配置这个属性了  
  24. -->  
  25.         <property name="configLocation" value="classpath:com/ztx/config/mybatis/MybatisConfig.xml" />  
  26.         <!-- 该配置文件用来指定Mapper映射文件的位置 ,如果映射文件与相应的接口同名,且在同一路径下,那么可以不配置该选项,也可以在MybatisConfig.xml文件里配置mapper-->  
  27.         <property name="mapperLocations" value="classpath:com/ztx/mapper/*Mapper.xml"/>  
  28.         <!-- 要映射类的包路径,如果使用了这种方式,则configLocation中不必再进行声明  
  29.      <property name="typeAliasesPackage" value="${mybatis.alias.basepackage}" />   -->  
  30.     </bean>  
  31.   
  32.     <bean id="userDao" class="org.mybatis.spring.mapper.MapperFactoryBean">  
  33.         <property name="mapperInterface" value="com.ztx.dao.UserDao" />  
  34.         <property name="sqlSessionFactory" ref="sqlSessionFactory" />  
  35.     </bean>  
  36.   
  37. </beans>  

8.spring-dataSource.xml

[html]  view plain  copy
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"  
  4.     xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"  
  5.     xsi:schemaLocation="  
  6.             http://www.springframework.org/schema/beans  
  7.             http://www.springframework.org/schema/beans/spring-beans.xsd  
  8.             http://www.springframework.org/schema/context  
  9.             http://www.springframework.org/schema/context/spring-context.xsd  
  10.             http://www.springframework.org/schema/aop  
  11.             http://www.springframework.org/schema/aop/spring-aop.xsd  
  12.             http://www.springframework.org/schema/tx  
  13.             http://www.springframework.org/schema/tx/spring-tx.xsd">  
  14.     <!-- <context:property-placeholder location="classpath:config/config.properties"   
  15.         /> <context:component-scan base-package="com.jqy.dao,com.jqy.service"></context:component-scan> -->  
  16.     <!-- 配置连接参数 -->  
  17.     <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">  
  18.         <property name="location" value="classpath:com/ztx/config/jdbc.properties"></property>  
  19.     </bean>  
  20.     <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"  
  21.         init-method="init" destroy-method="close">  
  22.         <property name="driverClassName" value="${driver}"></property>  
  23.         <property name="url" value="${url}"></property>  
  24.         <property name="username" value="${username}"></property>  
  25.         <property name="password" value="${password}"></property>  
  26.         <!-- 初始化链接大小 -->  
  27.         <property name="initialSize" value="0"></property>  
  28.         <!-- 连接池最大使用链接数量 -->  
  29.         <property name="maxActive" value="20"></property>  
  30.         <!-- 连接池最小空闲数量 -->  
  31.         <property name="minIdle" value="0"></property>  
  32.     </bean>  
  33.   
  34.     <!-- 数据源定义,使用 C3P0 连接池 -->  
  35.     <!-- <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"   
  36.         destroy-method="close"> <property name="driverClass" value="${driver}" />   
  37.         <property name="jdbcUrl" value="${url}" /> <property name="user" value="${username}"   
  38.         /> <property name="password" value="${password}" /> <property name="automaticTestTable"   
  39.         value="test_c3p0" /> -->  
  40.     <!--连接池中保留的最大连接数。Default: 15 -->  
  41.     <!-- <property name="maxPoolSize" value="10" /> -->  
  42.     <!--连接池中保留的最小连接数。 -->  
  43.     <!-- <property name="minPoolSize" value="2" /> -->  
  44.     <!--初始化时获取的连接数,取值应在minPoolSize与maxPoolSize之间。Default: 3 -->  
  45.     <!-- <property name="initialPoolSize" value="2" /> -->  
  46.     <!--最大空闲时间,60秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 -->  
  47.     <!-- <property name="maxIdleTime" value="60" /> -->  
  48.     <!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 -->  
  49.     <!-- <property name="acquireIncrement" value="2" /> </bean> -->  
  50.   
  51.     <!--====事务相关控制==-->   
  52.     <bean id="transactionManager"   
  53.         class="org.springframework.jdbc.datasource.DataSourceTransactionManager">   
  54.         <property name="dataSource" ref="dataSource" />   
  55.     </bean>   
  56.     <tx:advice id="userTxAdvice" transaction-manager="transactionManager">   
  57.         <tx:attributes>   
  58.         <!-- 没有配置只读 -->  
  59.             <tx:method name="find*"   propagation="SUPPORTS" read-only="true"/>  
  60.              <tx:method name="get*"    propagation="SUPPORTS" read-only="true"/>  
  61.              <tx:method name="query*"  propagation="SUPPORTS" read-only="true"/>  
  62.              <tx:method name="select*" propagation="SUPPORTS" read-only="true"/>  
  63.             <tx:method name="*" propagation="REQUIRED" rollback-for="java.lang.Exception"/>  
  64.         </tx:attributes>   
  65.     </tx:advice>   
  66.     <aop:config>   
  67.         <aop:pointcut id="pc"   
  68.             expression="execution(* com.ztx.service..*.*(..))" />   
  69.              <!-- 把事务控制在Business层 -->   
  70.         <aop:advisor pointcut-ref="pc" advice-ref="userTxAdvice" />   
  71.     </aop:config>   
  72. </beans>  

9.struts.xml

[html]  view plain  copy
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <!DOCTYPE struts PUBLIC  
  3.         "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"  
  4.         "http://struts.apache.org/dtds/struts-2.0.dtd">  
  5. <struts>  
  6.     <!-- 指定由spring负责action对象的创建 -->  
  7.     <constant name="struts.objectFactory" value="spring"></constant>  
  8.     <!-- 所有匹配*。action的请求都有struts2处理 -->  
  9.     <constant name="struts.action.extension" value="action,do,"></constant>  
  10.     <!-- 是否应用开发模式 -->  
  11.     <constant name="struts.devMode" value="true"></constant>  
  12.     <!-- struts配置文件改动后是否重新加载,2.3.14之前的版本有效 -->  
  13.     <constant name="struts.configuration.xml.reload" value="true"></constant>  
  14.     <!-- 设置浏览器是否缓存静态内容,生产环境中可设置为true -->  
  15.     <constant name="struts.serve.static.browserCache" value="false"></constant>  
  16.     <!-- 请求参数的编码方式 -->  
  17.     <constant name="struts.i18n.encoding" value="UTF-8"></constant>  
  18.     <!-- 每次HTTP请求都重新加载系统资源,有助于开发-->  
  19.     <constant name="struts.i18n.reload" value="true"></constant>  
  20.     <!-- 文件上传最大值 -->  
  21.     <constant name="struts.multipart.maxSize" value="104857600"></constant>  
  22.     <!-- 让struts2支持动态方法调用 -->  
  23.     <constant name="struts.enable.DynamicMethodInvocation" value="true"></constant>  
  24.     <!-- action名称中是否还是用斜线-->  
  25.     <constant name="struts.enable.SlashesInActionNames" value="false"></constant>  
  26.     <!-- 允许标签中使用表达式语法-->  
  27.     <constant name="struts.tag.Syntax" value="true"></constant>  
  28.     <!-- 对于WebLogic,Orion,OC4J此属性设置为true-->  
  29.     <constant name="struts.dispather.parametersWorkaroud" value="false"></constant>  
  30.   
  31.     <!--<package name="basePackage-struts" extends="struts-default">  
  32.   
  33.     </package>-->  
  34.   
  35. </struts>  

10.MybatisConfig.xml

[html]  view plain  copy
  1. <?xml version="1.0" encoding="UTF-8" ?>  
  2. <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"  
  3. "http://mybatis.org/dtd/mybatis-3-config.dtd">  
  4. <!--  didn't use -->  
  5. <configuration>  
  6.     <!-- MyBatis 按照如下的顺序加载它们 1.在 properties 元素体内指定的属性首先被读取。 2.从类路径下资源或 properties   
  7.         元素的 url 属性中加载的属性第二被读取,它会 覆盖已经存在的完全一样的属性。 3.作为方法参数传递的属性最后被读取,它也会覆盖任一已经存在的完全一样的   
  8.         属性,这些属性可能是从 properties 元素体内和资源/url 属性中加载的。 -->  
  9.     <!-- <properties resource="com/bupt/mybatis/config.properties">  
  10.         <property name="username" value="root" />  
  11.         <property name="password" value="yang1290" />  
  12.     </properties> -->  
  13.   
  14.     <settings>  
  15.         <!-- 这个配置使全局的映射器启用或禁用缓存。|true,false|true -->  
  16.         <setting name="cacheEnabled" value="true" />  
  17.         <!-- 全局启用或禁用延迟加载。当禁用时,所有关联对象都会即时加载。|true,false|true -->  
  18.         <setting name="lazyLoadingEnabled" value="true" />  
  19.         <!-- 当启用时,有延迟加载属性的对象在被调用时将会完全加载任意属性。否则, 每种属性将会按需要加载。|true,false|true -->  
  20.         <setting name="aggressiveLazyLoading" value="true" />  
  21.         <!-- 允许或不允许多种结果集从一个单独 的语句中返回(需要适合的驱动)。|true,false|true -->  
  22.         <setting name="multipleResultSetsEnabled" value="true" />  
  23.         <!-- 使用列标签代替列名。不同的驱动在这 方便表现不同。参考驱动文档或充分测试两种方法来决定所使用的驱动。|true,false|true -->  
  24.         <setting name="useColumnLabel" value="true" />  
  25.         <!-- 允许 JDBC 支持生成的键。需要适合的驱动。如果设置为 true 则这个设置强制生成的键被使用,尽管一些驱动拒绝兼容但仍然有效(比如   
  26.             Derby)。|true,false|false -->  
  27.         <setting name="useGeneratedKeys" value="false" />  
  28.         <!-- 指定 MyBatis 如何自动映射列到字段/属性。PARTIAL只会自动映射简单, 没有嵌套的结果。FULL会自动映射任意复杂的结果(嵌套的或其他情况)。|NONE,   
  29.             PARTIAL, FULL| PARTIAL -->  
  30.         <setting name="autoMappingBehavior" value="PARTIAL" />  
  31.         <!-- 配置默认的执行器。SIMPLE 执行器没 有什么特别之处。REUSE 执行器重用 预处理语句。BATCH 执行器重用语句和批量更新   
  32.             |SIMPLE, REUSE, BATCH|SIMPLE -->  
  33.         <setting name="defaultExecutorType" value="SIMPLE" />  
  34.         <!-- 设置超时时间,它决定驱动等待一个数据库响应的时间。| Any positive integer |Not Set (null) -->  
  35.         <setting name="defaultStatementTimeout" value="25000" />  
  36.         <!--   设置但JDBC类型为空时,某些驱动程序 要指定值,default:OTHER-->    
  37.         <setting name="jdbcTypeForNull" value="NULL"/>   
  38.         <!-- <setting name="logImpl" value="LOG4J" />  -->  
  39.     </settings>  
  40.   
  41.     <!-- 类型别名是为 Java 类型命名一个短的名字。它只和 XML 配置有关,只用来减少类完全 限定名的多余部分。 -->  
  42.     <typeAliases>  
  43.     <!-- <typeAlias alias="partreplaceRecord" type="com.ztx.entity.PartreplaceRecord" />  
  44.         <typeAlias alias="partReplace" type="com.ztx.entity.PartReplace" />-->  
  45.         <typeAlias alias="User" type="com.ztx.entity.User" />  
  46.     </typeAliases>  
  47.     <!-- <mappers>  
  48.         <mapper resource="com/jqy/dao/mapper/JgxxMapper.xml"/>  
  49.     </mappers> -->  
  50. <!--   
  51.     <environments default="development">  
  52.         <environment id="development">  
  53.             <transactionManager type="JDBC" />  
  54.             <dataSource type="POOLED">  
  55.                 <property name="driver" value="${driver}" />  
  56.                 <property name="url" value="${url}" />  
  57.                 <property name="username" value="${username}" />  
  58.                 <property name="password" value="${password}" />  
  59.             </dataSource>  
  60.         </environment>  
  61.     </environments>  
  62.    
  63.     <mappers>  
  64.         <mapper resource="com/bupt/mybatis/Test.xml"/>  
  65.     </mappers>-->  
  66.   
  67. </configuration>  

11.jdbc.properties

[html]  view plain  copy
  1. driver = oracle.jdbc.driver.OracleDriver  
  2. url = jdbc:oracle:thin:@127.0.0.1:1521:xe  
  3. usernamexhy  
  4. passwordxhy  

12.web.xml

[html]  view plain  copy
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"  
  3.          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  4.          xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"  
  5.          version="3.1">  
  6.     <!--指定spring配置文件地址-->  
  7.     <context-param>  
  8.         <param-name>contextConfigLocation</param-name>  
  9.         <param-value>classpath:com/ztx/config/spring/spring-config.xml</param-value>  
  10.     </context-param>  
  11.     <!--spring监听器 只有用了监听器才能在web启动的时候的监听到-->  
  12.     <listener>  
  13.         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  
  14.     </listener>  
  15.     <!--struts2配置-->  
  16.     <filter>  
  17.         <filter-name>struts</filter-name>  
  18.         <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>  
  19.     </filter>  
  20.     <filter-mapping>  
  21.         <filter-name>struts</filter-name>  
  22.         <url-pattern>*.action</url-pattern>  
  23.     </filter-mapping>  
  24.     <welcome-file-list>  
  25.         <welcome-file>/index.jsp</welcome-file>  
  26.     </welcome-file-list>  
  27.   
  28. </web-app>  


13.pom.xml 

[html]  view plain  copy
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <project xmlns="http://maven.apache.org/POM/4.0.0"  
  3.          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  4.          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">  
  5.     <modelVersion>4.0.0</modelVersion>  
  6.     <groupId>import</groupId>  
  7.     <artifactId>import</artifactId>  
  8.     <packaging>war</packaging>  
  9.     <version>1.0-SNAPSHOT</version>  
  10.     <name>import Maven Webapp</name>  
  11.     <url>http://maven.apache.org</url>  
  12.     <dependencies>  
  13.         <dependency>  
  14.             <groupId>org.apache.poi</groupId>  
  15.             <artifactId>poi</artifactId>  
  16.             <version>3.12</version>  
  17.         </dependency>  
  18.         <dependency>  
  19.             <groupId>org.apache.poi</groupId>  
  20.             <artifactId>poi-ooxml</artifactId>  
  21.             <version>3.12</version>  
  22.         </dependency>  
  23.         <dependency>  
  24.             <groupId>org.eclipse.birt.runtime.3_7_1</groupId>  
  25.             <artifactId>org.apache.xerces</artifactId>  
  26.             <version>2.9.0</version>  
  27.         </dependency>  
  28.         <dependency>  
  29.             <groupId>org.apache.directory.studio</groupId>  
  30.             <artifactId>org.dom4j.dom4j</artifactId>  
  31.             <version>1.6.1</version>  
  32.         </dependency>  
  33.         <dependency>  
  34.             <groupId>net.sourceforge.javacsv</groupId>  
  35.             <artifactId>javacsv</artifactId>  
  36.             <version>2.0</version>  
  37.         </dependency>  
  38.         <dependency>  
  39.             <groupId>commons-net</groupId>  
  40.             <artifactId>commons-net</artifactId>  
  41.             <version>3.3</version>  
  42.         </dependency>  
  43.         <dependency>  
  44.             <groupId>org.jodd</groupId>  
  45.             <artifactId>jodd-props</artifactId>  
  46.             <version>3.6.6</version>  
  47.         </dependency>  
  48.         <dependency>  
  49.             <groupId>org.slf4j</groupId>  
  50.             <artifactId>slf4j-api</artifactId>  
  51.             <version>1.7.12</version>  
  52.         </dependency>  
  53.         <dependency>  
  54.             <groupId>org.slf4j</groupId>  
  55.             <artifactId>slf4j-log4j12</artifactId>  
  56.             <version>1.7.12</version>  
  57.         </dependency>  
  58.         <dependency>  
  59.             <groupId>com.jcraft</groupId>  
  60.             <artifactId>jsch</artifactId>  
  61.             <version>0.1.53</version>  
  62.         </dependency>  
  63.         <dependency>  
  64.             <groupId>javax.servlet</groupId>  
  65.             <artifactId>javax.servlet-api</artifactId>  
  66.             <version>3.1.0</version>  
  67.             <scope>provided</scope>  
  68.         </dependency>  
  69.         <dependency>  
  70.             <groupId>javax.servlet.jsp</groupId>  
  71.             <artifactId>jsp-api</artifactId>  
  72.             <version>2.1</version>  
  73.             <scope>provided</scope>  
  74.         </dependency>  
  75.         <dependency>  
  76.             <groupId>com.google.code.gson</groupId>  
  77.             <artifactId>gson</artifactId>  
  78.             <version>2.5</version>  
  79.         </dependency>  
  80.         <dependency>  
  81.             <groupId>commons-collections</groupId>  
  82.             <artifactId>commons-collections</artifactId>  
  83.             <version>3.2.1</version>  
  84.         </dependency>  
  85.         <dependency>  
  86.             <groupId>junit</groupId>  
  87.             <artifactId>junit</artifactId>  
  88.             <version>4.12</version>  
  89.         </dependency>  
  90.         <dependency>  
  91.             <groupId>org.aspectj</groupId>  
  92.             <artifactId>aspectjweaver</artifactId>  
  93.             <version>1.8.4</version>  
  94.         </dependency>  
  95.         <dependency>  
  96.             <groupId>aopalliance</groupId>  
  97.             <artifactId>aopalliance</artifactId>  
  98.             <version>1.0</version>  
  99.         </dependency>  
  100.         <dependency>  
  101.             <groupId>cglib</groupId>  
  102.             <artifactId>cglib-nodep</artifactId>  
  103.             <version>2.2.2</version>  
  104.         </dependency>  
  105.   
  106.         <!--spring核心包-->  
  107.         <dependency>  
  108.             <groupId>org.springframework</groupId>  
  109.             <artifactId>spring-core</artifactId>  
  110.             <version>3.2.3.RELEASE</version>  
  111.         </dependency>  
  112.         <dependency>  
  113.             <groupId>org.springframework</groupId>  
  114.             <artifactId>spring-beans</artifactId>  
  115.             <version>3.2.3.RELEASE</version>  
  116.         </dependency>  
  117.         <dependency>  
  118.             <groupId>org.springframework</groupId>  
  119.             <artifactId>spring-web</artifactId>  
  120.             <version>3.2.3.RELEASE</version>  
  121.         </dependency>  
  122.         <dependency>  
  123.             <groupId>org.springframework</groupId>  
  124.             <artifactId>spring-context</artifactId>  
  125.             <version>3.2.3.RELEASE</version>  
  126.         </dependency>  
  127.         <dependency>  
  128.             <groupId>org.springframework</groupId>  
  129.             <artifactId>spring-jdbc</artifactId>  
  130.             <version>3.2.3.RELEASE</version>  
  131.         </dependency>  
  132.         <dependency>  
  133.             <groupId>org.springframework</groupId>  
  134.             <artifactId>spring-webmvc</artifactId>  
  135.             <version>3.2.3.RELEASE</version>  
  136.         </dependency>  
  137.         <dependency>  
  138.             <groupId>org.springframework</groupId>  
  139.             <artifactId>spring-webmvc-portlet</artifactId>  
  140.             <version>3.2.3.RELEASE</version>  
  141.         </dependency>  
  142.     <!--struts2核心包-->  
  143.     <dependency>  
  144.         <groupId>org.apache.struts</groupId>  
  145.         <artifactId>struts2-core</artifactId>  
  146.         <version>2.3.4.1</version>  
  147.     </dependency>  
  148.     <!-- struts2注解包 -->  
  149.     <dependency>  
  150.         <groupId>org.apache.struts</groupId>  
  151.         <artifactId>struts2-convention-plugin</artifactId>  
  152.         <version>2.3.4.1</version>  
  153.     </dependency>  
  154.         <!--struts2和spring结合包-->  
  155.         <dependency>  
  156.             <groupId>org.apache.struts</groupId>  
  157.             <artifactId>struts2-spring-plugin</artifactId>  
  158.             <version>2.3.4.1</version>  
  159.         </dependency>  
  160.         <dependency>  
  161.             <groupId>junit</groupId>  
  162.             <artifactId>junit</artifactId>  
  163.             <version>4.12</version>  
  164.             <scope>test</scope>  
  165.         </dependency>  
  166.         <!-- Mybatis 和Spring的 整合包,是mybatis出的 -->  
  167.         <dependency>  
  168.             <groupId>org.mybatis</groupId>  
  169.             <artifactId>mybatis-spring</artifactId>  
  170.             <version>1.2.2</version>  
  171.         </dependency>  
  172.         <!---->  
  173.         <dependency>  
  174.             <groupId>org.mybatis</groupId>  
  175.             <artifactId>mybatis</artifactId>  
  176.             <version>3.1.1</version>  
  177.         </dependency>  
  178.         <dependency>  
  179.             <groupId>com.oracle</groupId>  
  180.             <artifactId>ojdbc6</artifactId>  
  181.             <version>1.0</version>  
  182.         </dependency>  
  183.         <dependency>  
  184.             <groupId>com.alibaba</groupId>  
  185.             <artifactId>druid</artifactId>  
  186.             <version>1.0.14</version>  
  187.         </dependency>  
  188.         <dependency>  
  189.             <groupId>aopalliance</groupId>  
  190.             <artifactId>aopalliance</artifactId>  
  191.             <version>1.0</version>  
  192.         </dependency>  
  193.         <dependency>  
  194.             <groupId>cglib</groupId>  
  195.             <artifactId>cglib-nodep</artifactId>  
  196.             <version>2.2.2</version>  
  197.         </dependency>  
  198.     </dependencies>  
  199.   
  200.     <build>  
  201.         <finalName>import</finalName>  
  202.         <resources>  
  203.             <resource>  
  204.                 <directory>src/main/java</directory>  
  205.                 <includes>  
  206.                     <include>**/*.sql</include>  
  207.                     <include>**/*.xml</include>  
  208.                 </includes>  
  209.                 <filtering>false</filtering>  
  210.             </resource>  
  211.             <resource>  
  212.                 <directory>src/main/resources</directory>  
  213.                 <includes>  
  214.                     <include>**/*.properties</include>  
  215.                     <include>**/*.xml</include>  
  216.                     <include>**/*.props</include>  
  217.                 </includes>  
  218.                 <filtering>false</filtering>  
  219.             </resource>  
  220.         </resources>  
  221.         <plugins>  
  222.             <plugin>  
  223.                 <artifactId>maven-compiler-plugin</artifactId>  
  224.                 <version>2.3.2</version>  
  225.                 <configuration>  
  226.                     <source>1.7</source>  
  227.                     <target>1.7</target>  
  228.                 </configuration>  
  229.             </plugin>  
  230.             <plugin>  
  231.                 <artifactId>maven-war-plugin</artifactId>  
  232.                 <version>2.2</version>  
  233.                 <configuration>  
  234.                     <!--<version>3.0</version>-->  
  235.                     <failOnMissingWebXml>false</failOnMissingWebXml>  
  236.                 </configuration>  
  237.             </plugin>  
  238.         </plugins>  
  239.     </build>  
  240. </project>  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值